小编Vul*_*ria的帖子

(ProgressBar)findViewById(R.id.ProgressBar)返回null

进度条始终返回null

 public void calcola(View view) {
     final Dialog myDialog = new Dialog(this);
        myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        myDialog.setContentView(R.layout.calcdialog);
        myDialog.setCancelable(false);

        Typeface typeFace = Typeface.createFromAsset(getAssets(),"font/Flower.ttf");
        mProgress = (ProgressBar) findViewById(R.id.ProgressBar);

        TextView calc = (TextView) myDialog.findViewById(R.id.textView1);
        calc.setTypeface(typeFace);
        myDialog.show(); }
Run Code Online (Sandbox Code Playgroud)

这是我的xml

 <ProgressBar
    android:id="@+id/ProgressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:maxHeight="30dp"
    android:minHeight="30dp" />
Run Code Online (Sandbox Code Playgroud)

同一布局的textview工作得很完美,任何想法?

谢谢

android progress-bar

5
推荐指数
1
解决办法
3861
查看次数

标签 统计

android ×1

progress-bar ×1