2017-04-15 8 views
-1

geklickt wird habe ich eine App, den Inhalt eines Posts zeigt, während die Recycler Ansicht geklickt wird es eine neue Aktivität öffnetAnzeige Fortschrittsbalken während Recycler Ansicht

 @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); 


    } 

alles, was ich acheive will für einen Fortschrittsbalken gesetzt wird mindestens 3 Sekunden bevor die andere Aktivität angezeigt wird, danke.

+0

Sieht aus wie Sie die gleiche Frage vor lol gestellt: http://stackoverflow.com/questions/41808057/how-to-set-progress-bar-when-recycler-view-is-clicked – Aaron

+0

haben Sie die Antwort oder nicht? –

Antwort

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); 
        } 
       }); 
      } 

    } 

Ich hoffe, es funktioniert für Sie.
Happy Coding.

+0

danke für die antwort, aber ich freute mich auf eine Fortschrittsanzeige nicht auf einen Fortschrittsdialog. Vielen Dank –

Verwandte Themen