android - Anomailies when an activity calls itself -


i have activty in app uses putextra(int) method pass value 0 first when aactivty started. on pressing next button passes 6,subsequently 12 , on. trouble on pressing next second time found value of index received using getextras method 0.is cause calling activity . code snippet:

package com.movie;   import android.app.activity;  import android.content.intent;  import android.os.bundle;  import android.util.log;  import android.view.view;  import android.view.view.onclicklistener;  import android.view.window;   import android.view.windowmanager;  import android.widget.button;  import android.widget.toast;   public class movielist extends activity implements onclicklistener{  button bm[] = new button[6]; button nxt,prev; string namesdb[]=new string[50]; databaseconnect db; string lang; int start,index,end; public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     requestwindowfeature(window.feature_no_title);     getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,                              windowmanager.layoutparams.flag_fullscreen);     setcontentview(r.layout.mallu_list);     db = new databaseconnect(this);     db.open();      start=this.getintent().getextras().getint("index");      lang =this.getintent().getextras().getstring("lang");       toast.maketext(this, start+"", toast.length_short).show();      log.i("info",start+"");      if(!db.isdata(lang))     {         toast.maketext(this, "no data in database", toast.length_short).show();         finish();         return;     }     end=start+6;     bm[0] = (button) findviewbyid(r.id.bm1);     bm[1] = (button) findviewbyid(r.id.bm2);     bm[2] = (button) findviewbyid(r.id.bm3);     bm[3] = (button) findviewbyid(r.id.bm4);     bm[4] = (button) findviewbyid(r.id.bm5);     bm[5] = (button) findviewbyid(r.id.bm6);      nxt = (button) findviewbyid(r.id.nxt);     prev = (button) findviewbyid(r.id.prev);     if(start==0)     { //      prev.setbackgroundresource(0); //      prev.settext("");     }     else         prev.setonclicklistener(this);       namesdb = db.getmovie("",lang);     (int = 0; start+i < namesdb.length && i<6; i++) {         bm[i].settext(namesdb[start+i]);         bm[i].setonclicklistener(this);     }     int flag=0;     int i=namesdb.length;     log.i("info",i+"");         toast.maketext(this, i+"", toast.length_short).show();         for(int j=5;j>=i-start;j--)         {             bm[j].setbackgroundresource(0);             flag=1;         }     if(flag==1)     { //      nxt.setbackgroundresource(0); //      nxt.settext("");     }     else         nxt.setonclicklistener(this);   }  @override public void onbackpressed() {     // todo auto-generated method stub     super.onbackpressed();     intent myint2 = new intent(this, list.class);      startactivity(myint2); }     @override public void onclick(view v) {     // todo auto-generated method stub     switch (v.getid()) {     case r.id.bm1:         call(namesdb[start],start,lang);         break;     case r.id.bm2:         call(namesdb[start+1],start,lang);         break;     case r.id.bm3:         call(namesdb[start+2],start,lang);         break;     case r.id.bm4:         call(namesdb[start+3],start,lang);         break;     case r.id.bm5:         call(namesdb[start+4],start,lang);         break;     case r.id.bm6:         call(namesdb[start+5],start,lang);         break;      case r.id.nxt:         int i=namesdb.length;         intent myint2 = new intent(this,movielist.class);      myint2.putextra("index",end);     myint2.putextra("lang",lang);     startactivity(myint2);     case r.id.prev:         if(start==0)         {             prev.setbackgroundresource(0);         }         else         {          myint2 = new intent(this,movielist.class);      myint2.putextra("index",start-6);     myint2.putextra("lang",lang);     startactivity(myint2);}         break;      }  }  public void call(string name,int start2,string lang) {      intent myint = new intent(this, detail.class);     myint.putextra("nameid", name);     myint.putextra("index", start2);     myint.putextra("lang", lang);      startactivity(myint); }    } 

here's problem. part of switch statement:

case r.id.nxt:     int i=namesdb.length;     intent myint2 = new intent(this,movielist.class);     myint2.putextra("index",end);     myint2.putextra("lang",lang);     startactivity(myint2); 

is missing break @ end. falls through next case, starts activity different extras.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -