すみません、私は新しいです:これは新しいです。a を使用しsimple_list_item_2
て 11 個のアイテムを表示します。これらの 11 項目は、 を使用してロードされHashMap
、次にSimpleAdapter
. これは、すべてを表示する際にうまく機能します。問題は、私がsetOnItemClickListener
行けないことです。コード:
public class TwoLineActivity extends ListActivity
{
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(2);
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.scrolllist);
// enter valid data, these 2 are the same as the remaining 9
HashMap<String, String> maplist;
maplist = new HashMap<String, String>();
maplist.put("line1", "a11 data");
maplist.put("line2", "asd asd ad 1234569780");
list.add(maplist);
maplist = new HashMap<String, String>();
maplist.put("line1", "a12 data");
maplist.put("line2", "asd asd ad 1234569781");
list.add(maplist);
String[] from = { "line1", "line2" };
int[] to = { android.R.id.text1, android.R.id.text2 };
SimpleAdapter adapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_2, from, to);
setListAdapter(adapter);`
ここまでは素晴らしいので、リストを取得します。リストからアイテムを選択できるようにしたいので、次の2行をコーディングしました
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener()
{ .....
次のエラーが表示されます
The method setAdapter(SimpleAdapter) is undefined for the type ArrayList<HashMap<String,String>>
と
The method setOnItemClickListener(new AdapterView.OnItemClickListener(){}) is undefined for the type ArrayList<HashMap<String,String>>