这是我的 onCreate() 函数:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
//inflate the view
View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_loading, null);
TextView loadingMessage = (TextView) view.findViewById(R.id.fragment_loading_message_textview);
loadingMessage.setText("test");
//the dialog
Dialog dialog;
//set the dialog views
int themeId = getDialogThemeId();
//if there is no theme
if (themeId == -1)
dialog = new Dialog(getActivity());
else
dialog = new Dialog(getActivity(),getDialogThemeId());
//remove background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
//remove title
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
//set the content view
dialog.setContentView(view);
//set cancel properties
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
return dialog;
}
这是我正在膨胀的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:background="@android:color/black">
<!-- spinner -->
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent" />
<!-- text -->
<TextView
android:id="@+id/fragment_loading_message_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="@android:style/TextAppearance.Large"
android:textColor="@android:color/white"
android:text="LOADING"/>
</LinearLayout>
虽然我正在调用 loadingMessage.setText("test") 加载消息一直在消息中向我显示“LOADING”......任何想法?