当前位置: 代码迷 >> Android >> 操作栏和列表视图(ArrayList)
  详细解决方案

操作栏和列表视图(ArrayList)

热度:114   发布时间:2023-08-04 12:12:06.0

添加ListView后,操作栏不可见,能否请您告诉我使其再次可见?此外,如何在此Java文件中创建SearchView?

MainActivity.java

public class MainActivity extends ListActivity {

    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        // 1. pass context and data to the custom adapter
        MyAdapter adapter = new MyAdapter(this, generateData());

        //2. setListAdapter
        setListAdapter(adapter);
    }

    private ArrayList<Item> generateData(){
        ArrayList<Item> items = new ArrayList<Item>();
        items.add(new Item("item1","description1"));
        items.add(new Item("item2", "description2"));
        items.add(new Item("item3", "description3"));

        return items;

    }
}

我认为您应该将AppCompatActivity与ListActiv插入的ListView一起使用

  相关解决方案