я пытаюсь загрузить список элементов из массивов ... я получаю ошибку во время выполнения
02-22 11: 22: 51.042: E / AndroidRuntime (1460): вызвано: java.lang.RuntimeException: Ваше содержимое должно иметь ListView, атрибут id которого 'android.R.id.list'
мой файл R.java
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
public static final int icon=0x7f020001;
}
public static final class id {
public static final int mylist=0x7f050000;
public static final int next=0x7f050005;
public static final int play=0x7f050004;
public static final int prev=0x7f050003;
public static final int seekbar=0x7f050002;
public static final int selectedfile=0x7f050001;
public static final int text1=0x7f050006;
}
public static final class layout {
public static final int audiolist=0x7f030000;
public static final int song_item=0x7f030001;
public static final int songlist=0x7f030002;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}
мой код:
@Override
public void onCreate(Bundle icicle) {
try {
super.onCreate(icicle);
setContentView(R.layout.audiolist);
ListView listView = (ListView) findViewById(R.id.mylist);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile"};
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values);
listView.setAdapter(spinnerArrayAdapter);
} catch (NullPointerException e) {
Log.v(getString(R.string.app_name), e.getMessage());
}
}
макет: аудиолист
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/mylist"
android:layout_weight="1.0"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/screen_background_light"
android:padding="10dip">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/selectedfile"
android:text="Not file selected"
android:textColor="@android:color/black"
android:gravity="center_horizontal"
android:singleLine="true"
android:ellipsize="middle"/>
<SeekBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/seekbar"
android:max="100"
android:paddingBottom="10dip"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@android:drawable/screen_background_light">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/prev"
android:src="@android:drawable/ic_media_previous"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/play"
android:src="@android:drawable/ic_media_play"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/next"
android:src="@android:drawable/ic_media_next"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>