2017-04-15 36 views
-1

我而回收視圖點擊它會打開一個新的活動顯示進度條而回收視圖點擊

 @Override 
    public void onClick(View v) { 

     int position = getAdapterPosition(); 
     FeedItem feeditem = this.feeditem.get(position); 
     Intent intent = new Intent(this.ctx, ContentActivity.class); 
     intent.putExtra("posturl", feeditem.getPostUrl()); 
     intent.putExtra("Author",feeditem.getAuthorname()); 
     intent.putExtra("excerpt",feeditem.getExcerpt()); 
     intent.putExtra("content",feeditem.getContent()); 
     intent.putExtra("title",feeditem.getTitle()); 
     intent.putExtra("date",feeditem.getdate()); 
     intent.putExtra("thumbnail",feeditem.getAttachmentUrl()); 
     this.ctx.startActivity(intent); 


    } 

所有我想acheive放在一個進度條,顯示一個帖子的內容的應用程序至少3秒鐘之前,其他活動正在顯示謝謝。

+0

看起來像你之前問lol相同的問題:http://stackoverflow.com/questions/41808057/how-to-set-progress-bar-when-recycler-view-is-clicked – Aaron

+0

你有答案或不? –

回答

0
Intent intent; //declare global 
ProgressDialog progress; //declare global because before start activity dismiss the dialog 
@Override 
    public void onClick(View v) { 

     int position = getAdapterPosition(); 
     FeedItem feeditem = this.feeditem.get(position); 
     intent = new Intent(this.ctx, ContentActivity.class); 
     intent.putExtra("posturl", feeditem.getPostUrl()); 
     intent.putExtra("Author",feeditem.getAuthorname()); 
     intent.putExtra("excerpt",feeditem.getExcerpt()); 
     intent.putExtra("content",feeditem.getContent()); 
     intent.putExtra("title",feeditem.getTitle()); 
     intent.putExtra("date",feeditem.getdate()); 
     intent.putExtra("thumbnail",feeditem.getAttachmentUrl()); 

//here start the progress bar 

     progress = new ProgressDialog(this); 
     progress.setMessage("Loading..."); 
     progress.setCancelable(false); 
     progress.show(); 

     //set the timer here for 3 second 
     Timer t = new Timer(); 
     t.schedule(new waitingtimer(), 3000); 

    } 


    //here is the class of timer 
    private class waitingtimer extends TimerTask { 
      @Override 
      public void run() { 

       runOnUiThread(new Runnable() { 

        @Override 
        public void run() { 

         progress.dismiss(); 
         //here start the activity 
         this.ctx.startActivity(intent); 
        } 
       }); 
      } 

    } 

我希望它適合你。
快樂編碼。

+0

感謝您的回覆,但我期待着一個進度條而不是進度對話框。謝謝 –