It's "@android:id/list" - NOT "@id/android:list".
25 декабря 2011 г. 12:55 пользователь KK <[email protected]>написал: > hi all, > I'm using FrameLayout and have defined two LinearLayouts embedded inside > the FrameLayout. Now for each LinearLayout I've a listview . The problem > I'm facing is picking the two listviews separately from my Java side code. > The default listivew in XML uses the standard defined ID as > *android:id="@id/android:list" > *and I'm not able to pick the right one. So I decided to give custom ids > to each of the list view like this in Layout1: > <ListView > android:id="@+id/list1" > android:layout_width="fill_parent" > android:layout_height="fill_parent" /> > > and the following in Layout2 > > <ListView > android:id="@+id/list2" > android:layout_width="fill_parent" > android:layout_height="fill_parent" /> > > and this is what I'm trying to use to pick the listviews separately, > > ListView listView1 = (ListView) findViewById(R.id.list1); > ListView listView2 = (ListView) findViewById(R.id.list2); > > With the above code in pace, I'm not getting any compilation errors. But > during run time I'm getting errors with this message: > * java.lang.RuntimeException: Your content must have a ListView > whose id attribute is 'android.R.id.list'* > > Are we not allowed to use custom IDs for listviews? If custom IDs are not > allowed, then what is the best way to handle the above problem? Would > appreciate if someone could point me to the right direction. > > BTW, I'm actually trying to define two layouts each with its own listview > and then I'm trying to animate between two UI screens each using one layout > and the default behavior gives only one of the listivew as picked by > "getListView()" which happens to be the 1st one, so my 2nd UI page is not > showing any listview. > > > Thanks, > KK > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

