你好,所以我创建了一个列表,我想添加操作栏。我对 android 很陌生,所以我想知道如何在使用 ListActivity 时添加操作栏。任何帮助将不胜感激。谢谢我的代码:
public class MainActivity extends ListActivity {
ArrayList<Item> items = new ArrayList<Item>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
items.add(new SectionItem("2x2 Matrices"));
items.add(new EntryItem("Adding 2 Matrices"));
items.add(new EntryItem("Subtracting 2 Matrices"));
items.add(new EntryItem("Multiplying 2 Matrices"));
items.add(new EntryItem("Multiplying by a constant"));
items.add(new EntryItem("Dividing 2 Matrices"));
items.add(new EntryItem("Negative of a Matrix"));
items.add(new EntryItem("Inverse of a Matrix"));
items.add(new EntryItem("Determinant of a Matrix"));
/*Section2*/
items.add(new SectionItem("3x3 Matrices"));
items.add(new EntryItem("Item 4"));
items.add(new EntryItem("Item 5"));
items.add(new EntryItem("Item 6"));
items.add(new EntryItem("Item 7"));
/*Section3*/
items.add(new SectionItem("Category 3"));
items.add(new EntryItem("Item 8"));
items.add(new EntryItem("Item 9"));
items.add(new EntryItem("Item 10"));
items.add(new EntryItem("Item 11"));
items.add(new EntryItem("Item 12"));
EntryAdapter adapter = new EntryAdapter(this, items);
setListAdapter(adapter);
}
}