android - Newbie setting up a ListView -
i starting out using android, basic question.
i have created array called prioritynames. want display in list , able make selection list. @ stage, cannot list display.
as starting point used short example windrealm.org tutorials appreciated. if can point me better example appreciated.
public class simplelistviewactivity extends activity { private listview mainlistview ; private arrayadapter<string> listadapter ; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); // find listview resource. mainlistview = (listview) findviewbyid( r.id.mainlistview ); listadapter = new arrayadapter<string>(this, r.layout.simplerow, r.array.prioritynames); mainlistview.setadapter(listadapter); }
}
you passing id r.array.prioritynames.
use:
getresources().getstringarray(r.array.prioritynames)
Comments
Post a Comment