Unfortunately HelloListView has stopped

前端 未结 2 1832
野性不改
野性不改 2021-01-25 05:00

I\'ve followed this tutorial but when I try to run the application I get Unfortunately HelloListView has stopped The IDE gives no warnings or errors.

My Hel

相关标签:
2条回答
  • 2021-01-25 05:58

    You have to add setContentView(R.layout.yourlayout) after the super.onCreate(savedInstanceState);

    the R.layout.yourlayout should look like this ( in folder res/layout ) :

    <?xml version="1.0" encoding="utf-8"?>
    <ListView 
      android:id="@android:id/list"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" />
    
    0 讨论(0)
  • 2021-01-25 05:58

    When you extend ListActivity, you need to have an xml which contains id as @android:id/list, then in your activity you need to setContentView(R.layout.yourxmlName); Here is tutorial.

    0 讨论(0)
提交回复
热议问题