欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

aaa

程序员文章站 2024-02-14 12:47:46
...
public class ListViewActivity extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        String s[] = new String[]{"A","B     <ListView android:id="@android:id/list" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false" />  ","C","D","E","F"};        
        
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, s);
        setListAdapter(adapter);
        
    }   
    
}

 

 Your must add this ListView with the ID @android:id/list to the main.xml file. orelse will accur the error:

   You must have a ListView with the ID  @android:id/list

 

 

     <ListView android:id="@android:id/list" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false" /> 
 

 

 

 

 

 

上一篇: URI 、URL 、URN 理解

下一篇: aaa