help with listview and R.layout.main (Android)

前端 未结 2 1557
难免孤独
难免孤独 2021-01-29 04:28

im quite new to android, so i apologise if this is a noob-ish question (:

i designed my list following the example found here: http://android-er.blogspot.com/2010/06/cus

2条回答
  •  旧巷少年郎
    2021-01-29 05:05

    1. You create your main.xml
    2. Add to it a ListView

      
      

    somedrawable_xml.xml could be any drawable example:

    
    
    
    
    
    

    Add a layout xmlFile myLayout.xml example: (I added imageView for demonstration) anyway what is important is the id of the textview

    
    
        
    
    

    finally in your Activity

    ArrayAdapter myAD=new ArrayAdapter(mContext,R.layout.myLayout,R.id.thisIsTheTextView,new String[] {"item1", "item2", "item3", "item4", "item5"});
    myListView.setAdapter(myAD);
    

提交回复
热议问题