Android, intent error "not defined" -


my eclipse gives error message intents in switch: the constructor intent (new adapter.view.onitemclicklistener(){}, class <ulohashoweractivity>) undefined

all project intents ok, can reason. don't know wrong statement. using these intents other activities , works great, activities in manifest , ... in switch , onitemclick there error.

here's code activity,

public class hladajlistactivity extends activity  { private databaseop mdbhelper; public static final string how = "how"; public static final string name = "name"; public static final string date = "date"; public static final string typ = "typ";  int how; string name; string date; int typ;  string username; string nazov; string datum;  listview listview;  @override protected void oncreate(bundle savedinstancestate)  {     super.oncreate(savedinstancestate);     setcontentview(r.layout.hladaj);      intent = getintent();     how = integer.parseint(i.getstringextra(how));     name = i.getstringextra(name);     date = i.getstringextra(date);     typ = integer.parseint(i.getstringextra(typ));      listview = (listview) findviewbyid(r.id.listhladaj);      mdbhelper = new databaseop(this);     mdbhelper.open();      showusersettings();      cursor hladajcursor = mdbhelper.fetchallfind(username, name, date, how, typ);      final hladajcursoradapter adapter = new hladajcursoradapter(this, hladajcursor);     listview.setadapter(adapter);      if (listview.getcount()==0)         setcontentview(r.layout.hladaj_empty);      listview.setonitemclicklistener(new onitemclicklistener()      {         @override         public void onitemclick(adapterview<?> arg0, view arg1, int stlpec, long arg3)          {             // todo auto-generated method stub             cursor cur = (cursor) adapter.getitem(stlpec);              string typ = cur.getstring(cur.getcolumnindex("typ"));             string odosli = cur.getstring(cur.getcolumnindex("_id"));              switch (integer.parseint(typ))              {                 case 0:                     intent intent = new intent(this,ulohashoweractivity.class);                     intent.putextra(ulohashoweractivity.odosli, odosli);                      startactivity(intent);                     break;                 case 1:                     intent intent = new intent(this,predmetshoweractivity.class);                     intent.putextra(predmetshoweractivity.odosli, odosli);                      startactivity(intent);                     break;                 case 2:                     intent intent = new intent(this,poznamkashoweractivity.class);                     intent.putextra(poznamkashoweractivity.odosli, odosli);                      startactivity(intent);                     break;             }         }     }); }  @override public void onpause()  {     super.onpause();     mdbhelper.close(); }   private void showusersettings()  {     sharedpreferences sharedprefs = preferencemanager.getdefaultsharedpreferences(this);      username = sharedprefs.getstring("prefusername", "null"); }  } 

you should change this

intent intent = new intent(this,ulohashoweractivity.class); 

to

intent intent = new intent(hladajlistactivity.this,ulohashoweractivity.class); 

and change other cases. have pass activity context first argument of intent.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -