android - InflateExceptionError- line 40 -
so every time switch 1 activity has listview component, keep getting inflateexception
when tries load list view. here code activity list view:
public class userindexactivity extends activity { private accountdao accountdatasource; public static final string prefs_name = "mypreferencefile"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_user_index); accountdatasource = new accountdao(this); accountdatasource.open(); sharedpreferences settings = getsharedpreferences(prefs_name, 0); string userid = settings.getstring("userid", "default"); list<account> acclistquery = accountdatasource.getallaccounts(userid); list<string> list = new arraylist<string>(); for(account : acclistquery) list.add("account name: " + a.getdisplayname() + " \t balance: " + a.getbalance() + " \t interest rate: " + a.getinterestrate()); // arraylist<string> list = new arraylist<string>(); // list.add("asdfasdfasfd"); // list.add("asdfasfas"); // list<string> list = (arraylist)accountdatasource.getallaccounts(userid); listview listview = (listview)findviewbyid( r.id.listview); final arrayadapter<string> adapter = new arrayadapter<string>( this, android.r.layout.simple_list_item_1, list ); listview.setadapter( adapter ); listview.setclickable(true); final listview tempview = listview; listview.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> arg0, view arg1, int position, long arg3) { account o = (account)tempview.getitematposition(position); intent intent = new intent(userindexactivity.this,transactionactivity.class); startactivity(intent); } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.user_index, menu); return true; } public void addaccount(view view){ intent intent = new intent(this, addaccountactivity.class); startactivity(intent); } }
how hell fix error?
Comments
Post a Comment