• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps ArrayAdapter question

LeonR

Newbie
As im new, i'm obviously trying to learn and figure everything out still..

I'm simply trying to update a listview...

I created ListView01 on my main.xml .

Then using various examples, i have the following code..

Code:
public class UItestAct extends ListActivity {
    /** Called when the activity is first created. */
    
     static final String[] COUNTRIES = new String[] {
            "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra"};
    
    
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        
        ListView myListView = (ListView)findViewById(R.id.ListView01);
        
    
        
        
        ArrayAdapter<String> myAdaptor = new ArrayAdapter<String>(this,R.layout.main,COUNTRIES);
        
        
        myListView.setAdapter(myAdaptor);
        
        
        //setListAdapter(myAdaptor);
       // getListView().setTextFilterEnabled(true);
        
      }
    
    
    
    
    
}



I'm not exactly sure how to reference my main.xml layout? What am I doing wrong? :confused:


Thanks!! :)
 
May of fixed it now!

Code:
public class UItestAct extends Activity {
    /** Called when the activity is first created. */
    
     static final String[] COUNTRIES = new String[] {
            "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra"};
    
    
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        
        ListView myListView = (ListView)findViewById(R.id.ListView01);
    
        
       ArrayAdapter<String> myAdaptor = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,COUNTRIES);
         
        
        myListView.setAdapter(myAdaptor);
       
        
       // getListView().setTextFilterEnabled(true);
        
      }
    
    
    
    
    
}
 
God I hate method overloading. That array adapter constructor looked so weird to me until i looked it up and realized there are like 5 different signatures for the constructor. :(
 
Back
Top Bottom