android– 将循环进度条用作alertdialog或progressdialog

android– 将循环进度条用作alertdialog或progressdialog,第1张

概述我正在使用这个库为我的android服装创建一个循环进度条(https://github.com/lzyzsd/CircleProgress).我创建了一个布局,其中定义了循环进度条.<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apkes/android"xml

我正在使用这个库为我的android服装创建一个循环进度条(https://github.com/lzyzsd/CircleProgress).
我创建了一个布局,其中定义了循环进度条.

 <?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:custom="http://schemas.androID.com/apk/res-auto"    androID:orIEntation="vertical"    androID:background="#000000"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:ID = "@+ID/progress_layout_ID">    <com.github.lzyzsd.circleprogress.ArcProgress        androID:ID="@+ID/m_arc_progress"        androID:layout_wIDth="214dp"        androID:layout_height="match_parent"    /></linearLayout>

我想要这个布局,其中定义循环Progressbar作为alertdialog或progress对话框d出.我能够做到这一点.这是代码.

public class progressbar_fragment extends AlertDialog {    ArcProgress m_arc;    VIEw v;    int mProgressVal;    Context mContext;    protected progressbar_fragment(Context context) {    super(context);    mContext = context;}@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    m_arc = (ArcProgress) findVIEwByID(R.ID.m_arc_progress);    if (mProgressVal > 0) {        setProgress(mProgressVal);    }}@OverrIDepublic voID show() {    super.show();    setContentVIEw(R.layout.pogress_bar);}

我在类文件中称它为

    m_arc = new progressbar_fragment(m_caller_context);    m_arc.show();

因此循环进度条显示为alertdialog.现在我想通过代码设置进度.任何人都可以指导我如何做到这一点设置进度功能是在库代码中.

应该有某种方式

m_arc_progress = (ArcProgress) l_progress_layout.findVIEwByID(R.ID.m_arc_progress);    m_arc_progress.setProgress(0);

有时它只适用于初始案例和我尝试做的时候

m_arc_progress.setProgress(25);

它告诉我错误

> java.lang.NullPointerException: Attempt to invoke virtual method> 'androID.vIEw.VIEw androID.vIEw.Window.findVIEwByID(int)' on a null> object reference

请帮忙做什么.

@H_419_54@解决方法:

你已经设置了setContentVIEw(R.layout.pogress_bar);在显示对话框后你必须在执行findVIEwByID之前在onCreate()中设置它

总结

以上是内存溢出为你收集整理的android – 将循环进度条用作alertdialog或progressdialog全部内容,希望文章能够帮你解决android – 将循环进度条用作alertdialog或progressdialog所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1117302.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存