vtking vtking - 11 months ago 106
Android Question

how to override getView() method in activity extend Listactivity

My project have a listview and MainActivity extend ListActivity, so I work "Alt+Shift+S" to add method getView() but I can not find getView() in this list.

Please show me, I need call getView() method.
Thank you!


getView() is a method of List adapter. So to Override it you need to set a custom adapter to your activity ref: http://www.vogella.com/tutorials/AndroidListView/article.html

public class MySimpleArrayAdapter extends ArrayAdapter<String> {
  public MySimpleArrayAdapter(Context context, String[] values) {

  public View getView(int position, View convertView, ViewGroup parent) {
    return rowView;

in your Activity:

public void onCreate(Bundle icicle) {
        MySimpleArrayAdapter<String> adapter = new MySimpleArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1, values);