Skip to content Skip to sidebar Skip to footer

Android Progressdialog

how can I display a ProgressDialog for this code? try{ leggiNews = Pattern.compile('

(.*?)(.*?)<

Solution 1:

You can do it using different Thread for Network operations as follows

ProgressDialog progress = ProgressDialog.show(this, "", "Loading ...", true);
 newThread(newRunnable(){
       @Overridepublicvoidrun(){
          try{
                leggiNews = Pattern.compile("<p><a href='(.*?)' class='rossobig'>(.*?)</a><br/>(.*?)</p>"); 
                leggi = leggiNews.matcher(getURL("http://www.example.com/"));
          } catch(UnknownHostException tt){
                         tt.printStackTrace();
          } catch (Exception e) {  
                           e.printStackTrace();
            } 
          runOnUiThread(newRunnable() {

                    @Overridepublicvoidrun() {
                        progress.dismiss();
                    }
                });

      }
 }).start();

Please make sure that object of ProgressDialog will be class variable here

Post a Comment for "Android Progressdialog"