I have searched the forum for the similar issue and as far as I can tell I am doing it the way other solutions suggest, but I still get the error "your content must have a listview whose id attribute is android.r.id.list"
My MainActivity.java looks like:
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
new ArrayList<String>()));
}
My activity_main.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="dk.beatpro.mibfinder.MainActivity"
tools:ignore="MergeRootFrame" />
And fragment_mail.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: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="dk.beatpro.mibfinder.MainActivity$PlaceholderFragment" >
<Button
android:id="@+id/button_findMIB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_findMIB" />
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_findMIB" />
</RelativeLayout>
But I get the following runtime error:
06-24 09:00:07.726: E/AndroidRuntime(10542): FATAL EXCEPTION: main
06-24 09:00:07.726: E/AndroidRuntime(10542): Process: dk.beatpro.mibfinder, PID: 10542
06-24 09:00:07.726: E/AndroidRuntime(10542): java.lang.RuntimeException: Unable to start activity ComponentInfo{dk.beatpro.mibfinder/dk.beatpro.mibfinder.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
Even though I have android:id="@android:id/list"
for the <ListView\>
element.
Can anyone tell me what I'm missing here?