How to use ArrayAdapter

后端 未结 5 1843
夕颜
夕颜 2020-11-22 14:23
ArrayList myList = new ArrayList();

ListView listView = (ListView) findViewById(R.id.list);

ArrayAdapter adapter = new         


        
5条回答
  •  难免孤独
    2020-11-22 14:38

    You could just add a toString() method to MyClass, per http://developer.android.com/reference/android/widget/ArrayAdapter.html:

    However the TextView is referenced, it will be filled with the toString() of each object in the array. You can add lists or arrays of custom objects. Override the toString() method of your objects to determine what text will be displayed for the item in the list.

    class MyClass {
    
     @Override
     public String toString() {
      return "Hello, world.";
     }
    }
    

提交回复
热议问题