IMA 내 목록보기에 이미지를 추가하려고하지만 난이 오류가있어 :안드로이드 비트 맵은 ListView에
You must supply a resource ID for a TextView
을이 메뉴의 레이아웃, menu.xml는 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sahovnica"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MenuActivity" >
<ImageView
android:id="@+id/imageView_Menu_Title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/app_name"
android:src="@drawable/vh_title" />
<ListView
android:id="@+id/listView_Menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageView_Menu_Title" >
</ListView>
이것은이다 list_item.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView_List_Item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
나는 내가 ArrayAdapter와 일부 문자열을 넣어 항목으로 텍스트 뷰 list_item.xml에 넣어 tryed하고 여전히 일을 일부러 있기 때문에 (오류)를 의미 할 것입니다 무엇을 잘 모릅니다
public class MenuActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
ListView list = (ListView)findViewById(R.id.listView_Menu);
Bitmap[] images = { decodeImage(R.drawable.igraj),
decodeImage(R.drawable.rezultati),
decodeImage(R.drawable.postavke),
decodeImage(R.drawable.pomoc), decodeImage(R.drawable.izlaz)};
ArrayAdapter<Bitmap> adapter = new ArrayAdapter<Bitmap>(this, R.layout.list_item,
images);
list.setAdapter(adapter);
}
private Bitmap decodeImage(int res) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),res);
return bitmap;
}
}
: 그리고 이것은 내 코드입니다 그러나 나는 이유를 알 수 없다. 미리 감사드립니다. ArrayAdapter
Documentation에서
사용자 정의 어댑터를 사용하십시오. – Raghunandan