我在从一个屏幕切换到另一个屏幕时显示进度条。 这是循环进度条,其中有一条消息“正在加载” 此消息显示在进度条的右侧。 我想在循环加载下面显示它。有可能吗?
progressDialog = ProgressDialog.show(test2.this, "", "Initializing", false);
Thread thread=new Thread(new Runnable(){
public void run(){
startActivity(new Intent(test2.this, test.class));
runOnUiThread(new Runnable(){
public void run() {
if(progressDialog.isShowing())
progressDialog.dismiss();
}});
}});
thread.start();
答案 0 :(得分:3)
为此你必须创建一个自定义对话框,如下所示修改它以满足你的需要
public static void showProgressDialog(Context mContext, String text, boolean remove)
{
mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
LayoutInflater mInflater = LayoutInflater.from(mContext);
View layout = mInflater.inflate(R.layout.popup_example, null);
mDialog.setContentView(layout);
TextView mTextView = (TextView) layout.findViewById(R.id.text);
if (text.equals(""))
mTextView.setVisibility(View.GONE);
else
mTextView.setText(text);
mDialog.setCancelable(remove);
// aiImage.post(new Starter(activityIndicator));
mDialog.show();
}
<强> popup_example.xml 强>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true">
<ProgressBar
android:id="@android:id/progress"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"></ProgressBar>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading Content"
android:layout_margin="10dip"
android:textColor="#FFFFFF"
android:layout_gravity="center_vertical" />
</LinearLayout>
</RelativeLayout>