The setListAdapter in ListView fails.

Asked 2 years ago, Updated 2 years ago, 44 views

I have a question about ListView in ActionBarActivity.I would like to display dummy data, but the bottom of the code below is

setListAdapter (this, ExampleItems);

There is an error in the error.
The error content is cannot resolve method 'setListAdapter'
Actually, I referred to the one I used in ListFragment, but ActionbarActivity seems to be different and I am having trouble.
Thank you for your cooperation.

@Override
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView (R.layout.example1);

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);


    // TODO:Delete dummy data
    ExampleItems=new ArrayList<ExampleElement>();

    int maxLength = 3;

    for (inti=0; i<maxLength;i++) {
        ExampleElement item = new ExampleElement();
        item.setAccountName("UserName");
        item.setImage(R.drawable.ic_launcher);
        ExampleItems.add(item);
    }

    setListAdapter(this,ExampleItems);

}

android

2022-09-30 19:44

1 Answers

ActionBarActivity is not ListActivity, so there is no setListAdapter() method...


2022-09-30 19:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.