android - ListView id not valid -


i've got problem activity root element listview. i've followed this tutorial load items listview , work. i've tried change id of listview , now, when activity loading, receive problem:

your content must have listview id attribute "android.r.id.list"

i retried change id "list" i've got same problem. don't have problems in compiling in run-time. code of activity when load listview.

public class startactivity extends listactivity {  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_start);      //section inflating     adapter.addsection(getstring(r.string.equationmenu), new arrayadapter<object>(this,             android.r.layout.simple_list_item_1, new string[] {getstring(r.string.eq1title), getstring(r.string.eq2title), getstring(r.string.eqfractitle)}));      setlistadapter(adapter); }  sectionedadapter adapter = new sectionedadapter() {     protected view getheaderview(string caption, int index,                                  view convertview, viewgroup parent) {         textview result = (textview) convertview;          if (convertview == null) {             result = (textview) getlayoutinflater().inflate(                     r.layout.header, null);         }          result.settext(caption);          return (result);     } }; } 

and xml of activity:

<?xml version="1.0" encoding="utf-8"?> <listview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawselectorontop="true" /> 

anyone can me? :)

if extend listactivity have let id of listview in xml

(android:id="@android:id/list")

if want change id or use more 1 listview in activity have extend activity , inflate listview yourself..

for example below:

listview list1 = (listview) findviewbyid(r.id.mylist1); list1.setadapter(...);

listview list2 = (listview) findviewbyid(r.id.mylist2); list2.setadapter(...);


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -