0
我有一個ListView與適配器:如何從基於Java的ListView選擇的項目,Android的
ListView names=(ListView)findViewById(R.id.listViewItems);
String[] items=new String[mMusicData.size()];
mMusicData.keySet().toArray(items);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, new String[]{"A", "B", "C"});
names.setAdapter(adapter);
當我試圖讓其他功能我總是得到-1所選項目的ID:
Log.e("1", String.valueOf(names.getSelectedItemPosition()));