java - The type of the expression must be an array type but it resolved to long -
i have problem, sought little can't figure why it's append ...
if me.
public class menu extends activity { private sqlitedatabase db; private gridview grid; private button add; private button info; private button deco; private string lab[]; private string id[]; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.menu); grid = (gridview) findviewbyid(r.id.grid); add = (button) findviewbyid(r.id.add_account); info = (button) findviewbyid(r.id.info); deco = (button) findviewbyid(r.id.deconnexion); add.setonclicklistener(add_listener); info.setonclicklistener(info_listener); deco.setonclicklistener(deco_listener); try { db = openorcreatedatabase("tmp_tttt_tla", mode_private, null); } catch(sqliteexception e) { toast.maketext(menu.this, "impossible d'avoir accès à la base de donnéee.", toast.length_long).show(); } cursor c = db.rawquery("select a_id, a_name account", null); lab = new string[c.getcount()]; id = new string[c.getcount()]; int = 0; if (c.getcount() != 0 ) { if (c.movetofirst()) { { lab[i] = c.getstring(c.getcolumnindex("a_name")); id[i] = c.getstring(c.getcolumnindex("a_id")); i++; } while(c.movetonext()); } } c.close(); grid.setadapter(new adapter_menu(this, lab)); grid.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview parent, view v, int position, long id) { intent x = new intent(menu.this, account_view.class); x.putextra("id", id[position]); startactivity(x); } }); } }
the problem come line :
x.putextra("id", id[position]);
it's type of expression must array type resolved long.
help me please.
the problem have 2 variables called id:
private string id[];
and
long id
of onitemclick
.
just change onitemclicklistener
following:
public void onitemclick(adapterview parent, view v, int position, long anid) { intent x = new intent(menu.this, account_view.class); x.putextra("id", id[position]); startactivity(x); }
please note name of last argument of onitemclick
.
Comments
Post a Comment