我想在我的android應用程序中的對話框中製作進度條,以便當用戶按下按鈕對話框時出現文本如「Please wait」和移動進度條。我不知道該怎麼做。在Android中的對話框中的進度條
下面是代碼:
package com.example.progressdialog;
import android.os.Bundle;
import android.view.View;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
ProgressDialog pd = new ProgressDialog(this);
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pleasewait();
}
public void pleasewait(View v){
pd.setTitle(「Hello」);
pd.show();
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please wait…"
android:onClick=」pleasewait」 />
</LinearLayout>
請在我的代碼更正或,如果可以的話,提出一些更好的辦法。
當我試圖建議
I am g使用此代碼設置太多錯誤... :( – LittleGirl 2014-09-18 23:22:51
是的,當然!:)可能是我缺少導入的東西。 – LittleGirl 2014-09-18 23:31:33
24錯誤.... :( – LittleGirl 2014-09-18 23:37:36