在列表視圖中我想輸入字符串數組。系統一直顯示一個錯誤——構造函數ArrayAdapter(QuizMenuActivity, int, String[])未定義。以下是代碼:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
ListView menuList=(ListView) findViewById(R.id.ListView_Menu);
String [] items = new String[] { getResources().getString(R.string.menu_item_Play),
getResources().getString(R.string.menu_item_scores),
getResources().getString(R.string.menu_item_settings),
getResources().getString(R.string.menu_item_help)};
ArrayAdapter <string> adapt = new ArrayAdapter<string> (this,
R.layout.menu_item, items);
menuList.setAdapter(adapt)
試用下這個:
/** 當activity第一次被創建時,調用: */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String [] items = new String[] { getResources().getString(R.string.menu_item_Play),
getResources().getString(R.string.menu_item_scores),
getResources().getString(R.string.menu_item_settings),
getResources().getString(R.string.menu_item_help)};
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));