我正在为我的对话框使用自定义布局来显示进度条和文本。布局看起来像
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/popuplayout"
android:padding="8dp">
<LinearLayout android:id="@+id/progressdialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_toLeftOf="@+id/textView1" />
<TextView
android:id="@+id/progressmsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:textStyle="bold"
android:textSize="15dp"
android:padding="5dp"
android:text="loading..." />
</LinearLayout>
</RelativeLayout>
并通过我的 util.java(不是活动)中的方法在对话框中分配此布局,例如
private static Dialog progressDialog = null;
public static void showLoadingProgress(String msg){
Log.d("EditorUtil", "show loading progress"+progressDialog);//No i18n
progressDialog = new Dialog(MainActivity.getActivity());
progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
progressDialog.setCancelable(false);
progressDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
progressDialog.setContentView(R.layout.customprogress);
TextView message = (TextView)progressDialog.findViewById(R.id.progressmsg);
message.setText(msg);
progressDialog.show();
Log.d("",progressDialog.isShowing()+""); //No i18n
}
调用此方法时,我无法看到对话框,但日志正在正确打印。请帮助解决这个问题。