警告ダイアログでリストをロードする前にprogressBarを表示したい場合は、そのためにAsyncTaskを使用してください。
例えば:
private class LoadingTask extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute(){
super.onPreExecute();
progressDialog.show();
}
@Override
protected String doInBackground(String... str) {
String response = "";
// Call Web Service here and return response
response = API.getDealsByCategory(str[0], str[1]);
// e.g.: above is my WebService Function which returns response in string
return response;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
System.out.println("result is: "+result);
new Thread(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
}
}).start();
// SHOW THE ALERT DIALOG HERE.....
}
}
以下のように AsyncTask を呼び出します。
LoadingTask タスク = 新しい LoadingTask(); task.execute("YOUR_PARAMETER","YOUR_PARAMETER");
//==============================
以下のコードを AsyncTask の Post Excution に入れるだけで、必要なものが得られます。
final CharSequence[] items = {"","50","100","150","200","250","300","350","400","450","500","550","600","650","700","750","800","850","900","1000"};
AlertDialog.Builder builder = new AlertDialog.Builder(getParent());
builder.setTitle("Select Country");
//builder.setI
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//Toast.makeText(getApplicationContext(), con.get(item).getCountrName(), Toast.LENGTH_SHORT).show();
selectDistanceTV.setText(items[item]);
System.out.println("Item is: "+items[item]);
/*CONTRY_ID = con.get(item).getCountryId();
stateET.requestFocus();*/
}
});
AlertDialog alert = builder.create();
alert.show();
それがあなたを助けることを願っています。
AsyncTask の使用方法についてさらにヘルプが必要な場合は、こちらを参照してください: Vogella
どんな質問でも私にコメントしてください。
コーディングを楽しんでください... :)