Resolution your content must has a ListView whose id attribute is ' Android. R.id.list '

Source: Internet
Author: User

1. Error HINT: Your content must has a ListView whose id attribute is ' Android. R.id.list '

For the above error, it may be because we want to implement the Setonitemclick in the ListView of event monitoring to inherit the liseactivity, but there is no listview tag, as long as in the layout file to add custom layout code, When the ListView ID is set to "@android:id/list" or android:id= "@id/android:list", you can use Getlistview to get the ListView object.

The XML code is as follows:


[HTML] View plaincopy <listview
Android:id= "@android: id/list" or android:id= "@id/android:list"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content" >
</ListView>


2. It is also easy to report this error with Tabhost, as follows:

Question 1. When running activity, your content must has a tabhost whose id attribute is ' Android. R.id.tabhost '

Add layout, XML and element selection Tabhost, but ADT did not add the id attribute, run, will prompt your content must have a tabhost

Whose id attribute is ' Android. R.id.tabhost ' ERROR, need to add android:id= "@android: Id/tabhost", so you can.

Question 2. When running activity, your tabhost must has a tabwidget whose id attribute is ' Android. R.id.tabcontent '

Workaround: Modify the Framelayout Add id attribute, the ADT Auto-generated XML file ID is android:id= "@+id/framelayout01", need to be modified to the next

The format of the polygon android:id= "@android: id/tabcontent", this estimate will bother a large number of beginners, who would have thought would modify this place, see the error easily

Modified to Tabcontent, but the prefix is not easy to think of. And in the ADT visual Editing this file, the interface shows NullPointerException, this is

A bug in ADT.

The modified XML is as follows:

<?xml version= "1.0″encoding=" utf-8″?>
<tabhost
Android:id= "@android: Id/tabhost"
Xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" >
<linearlayout android:id= "@+id/linearlayout01″android:layout_height=" Fill_parent "

Android:layout_width= "fill_parent" android:orientation= "vertical" >

<tabwidget android:id= "@android: Id/tabs" android:layout_height= "Wrap_content"

Android:layout_width= "Fill_parent" >
</TabWidget>
<framelayout android:id= "@android: Id/tabcontent" android:layout_width= "Fill_parent"

android:layout_height= "Fill_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>

Note: If you use Tabhost, the three places marked red must be the same, this is Google's agreement. And there can only be one tabhost in a project.

Source: http://blog.sina.com.cn/s/blog_5e58565701010bpj.html

Resolution your content must has a ListView whose id attribute is ' Android. R.id.list '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.