基本的な SimpleAdapter を必要としない状況で、どのアダプターを使用すればよいかはまだわかりません。BaseAdapter、ArrayAdapter、CustomAdapter などがあります。
Google PlayStore のコメント欄にあるようなシンプルなレイアウトの ListView を作りたいと思っています。一方の TextView と、ある種のコンテキスト メニューをポップアップするイメージ。
これに最適なアダプタはどれですか?
あなたの場合、を使用する方が簡単SimpleAdapter
です。カスタムレイアウトを提供し、データをウィジェットのIDに接続するだけです。これに似たもの:
List<HashMap<String,String>> datalist = new ArrayList<HashMap<String,String>>();
HashMap<String, String> map = new HashMap<String,String>();
map.put("text", "some text");
map.put("image",Integer.toString( R.drawable.your_image_to_popup_a_menu ));
datalist.add( map );
String[] from = { "text","image" };
int[] to = { R.id.txt,R.id.img };
SimpleAdapter adapter = new SimpleAdapter( this, datalist, R.layout.your_layout, from, to);
"@+id/txt"
レイアウトのTextViewとImageViewをそれぞれととして識別することを忘れないでください"@+id/img"
。
(画像が常に同じである場合は、レイアウトに設定し、R.id.img
パーツのリンクを忘れてください)