0
내 목표는 인터넷 연결이 없으면 (10 초 후) 사용자가 인터넷 연결을 확인하고 다시 시도하라는 다른 경고 대화 상자를 시작하는 경우 초기 진행 상황 표시를 닫는 것입니다.진행 표시를 닫고 다른 표시를 다시 실행하십시오.
이private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
/*
Create the progressdialog
*/
mProgressDialog = new ProgressDialog(MainActivity.this);
//title :
mProgressDialog.setTitle("SmartShop. Shopping made easy !");
//message :
mProgressDialog.setMessage("Chargement...");
mProgressDialog.setIndeterminate(false);
//show the progressdialog...Only if gpslocation is available !! :)
if (gps.canGetlocation()){
mProgressDialog.show();
}
//mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
long delayInMillis = 3000;
list_of_articles = new ArrayList<Articles>();
try {
timer.schedule(new TimerTask() {
@Override
public void run() {
mProgressDialog.dismiss();
}
},delayInMillis);
// Locate the class table named "Article" in Parse.com
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
"Article");
// Locate the column named "ranknum" in Parse.com and order list
// by ascending
//query.orderByAscending("ranknum");
query.whereWithinKilometers("Localisation_Vendeur",device_location,rayon);
ob = query.find();
for (ParseObject article : ob) {
// Locate images in article_image column
ParseFile image = (ParseFile) article.get("Image_Article");
Articles map = new Articles();
map.setArticle_name((String) article.get("Nom_Article"));
map.setArticle_vendor((String) article.get("Nom_Vendeur"));
//map.setArticle_vendor((String) article.get("reduction"));
map.setArticle_image(image.getUrl());
list_of_articles.add(map);
}
} catch (ParseException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.listview);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(MainActivity.this,
list_of_articles);
// Binds the Adapter to the ListView
listview.setAdapter(adapter);
// Close the progressdialog
mProgressDialog.dismiss();
}
}
내해서 ProgressDialog가이 코드를 해고하지 않습니다
여기 내 RemoteDataTask 클래스입니다. 그게 뭐가 잘못 됐니? 그리고 두 번째 alertdialog를 "인터넷 연결을 확인하고 다시 시도하십시오"라고 불러야합니까?
감사합니다.
답장을 보내 주셔서 감사합니다.하지만 "UI 스레드에서만 UI 수정을 수행해야합니다"라는 부분은 이해하지 못합니다. 튜토리얼/문서를 가르쳐 주시겠습니까? BTW 나는 타이머를 onPreExecute 함수로 옮겼고 이제는 prgressdialog가 닫습니다. – RidRoid
@RidouaneHicham http://developer.android.com/guide/components/processes-and-threads.html –