텍스트를 SimpleAdapter에 전달하는 동적 목록보기를 이미 만들었지 만 드로어 블 폴더에서 이미지를 표시하기위한 정보를 전달하고 싶습니다.안드로이드는 동적 목록보기에 이미지 추가
<ImageView
android:id="@+id/sport_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="2dp"
android:textSize="20dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<TextView
android:id="@+id/item_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:textSize="13dp" />
</LinearLayout>
</LinearLayout>
및 목록 작성하는 코드의 비트 : 나는를 통과 할 때 순간 지금
//fill in the list items from the XML document
for (int i = 0; i < nodes.getLength(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element)nodes.item(i);
map.put("id", XMLfunctions.getValue(e, "fixture_id"));
map.put("sport", XMLfunctions.getValue(e, "sport"));
map.put("teams", XMLfunctions.getValue(e, "team_2") + " v " + XMLfunctions.getValue(e, "team_2"));
mylist.add(map);
}
//Make a new listadapter
ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.fixture, new String[] { "sport", "teams" }, new int[] { R.id.item_title, R.id.item_subtitle });
setListAdapter(adapter);
을 여기에 각 행의 XML 레이아웃입니다 문자열 스포츠는 item_title 텍스트보기에서 '축구'와 같은 텍스트를 표시합니다. 하지만 스포츠가 뭔지 알기 때문에 sport_icon 이미지 뷰에 아이콘을 표시하고 싶습니다. 스포츠 아이콘 위치의 예는 @ drawable/icon_football입니다.
감사합니다.
여기에 대한 대답은 아래 Frank의 제안대로 ListView가있는 BaseAdapter를 만드는 것입니다. 다른 사람이 똑같은 일을하기를 원하지만 어디서부터 시작해야할지 모르겠다면 http://www.youtube.com/watch?v=pVs4qKmenQM을 시청하는 것이 좋습니다. 이 비디오는 잘 정리되어 있고 알아야 할 모든 것을 설명합니다.
: