<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/icon"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px"
android:src="@drawable/ic_launcher" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20px" >
</TextView>
</LinearLayout>
Выше мой layoutm «messages.xml
»ArrayAdapter требует идентификатор ресурса, чтобы быть TextView
public class TabClass extends ListFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
String[] values = new String[] { "label1", "label2", "label3"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
R.layout.messages, values);
setListAdapter(adapter);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
// Do something with the data
}
}
Я получаю эту ошибку, когда я пытаюсь скомпилировать приложение "ArrayAdapter requires the resource ID to be a TextView"
http://stackoverflow.com/questions/9280965/arrayadapter-requires-the-resource-id-to-be-a-textview-xml-problems – BobTheBuilder
http://stackoverflow.com/questions/8673829/arrayadapter -requires-id-to-be-a-textview-error – BobTheBuilder
http://stackoverflow.com/questions/6822632/error-arrayadapter-requires-the-resource-id-to-be-a-textview – BobTheBuilder