I am creating an android application using android studio
Main_Activity is a splash screen. Home_Activity is a TabActivity contains 3 tabs to three different forms one of them is a list activity
I have created a List_Activity that contains a list view , so I have set the activity type to ListActivity .
my problem is : when I start my app on my phone it gives errors
1:java.lang.RuntimeException: Unable to start activity Componentinfo{com.example.discopc.myapp/com.example.discopc.myapp.List1}: java.lang.RuntimeException: your content must have a ListView Whose Id attribute is 'android.R.id.list'
I have searched on Internet but didn't find any good answer.
The List_Activity will work fine if I Start it as a single app W/o other activities.
But when I use my splash screen and TabActivity app crash.
I have tried :
Using only List activity form but it starts normally ! I don't know why it won't start with my splash screen & tabview
Changing name of listview in List_activity
doing : android:id="@android:id/list" in XML files
--------------------------------------------------------------
public ListView list;
CODE : OnCreate of List1 Activity :
list = (ListView) findViewById(R.id.list);
deletbox = (CheckBox) findViewById(R.id.deletbox);
final ImageButton addButton = (ImageButton) findViewById(R.id.addButton);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
boolean isChecked = ((CheckBox) findViewById(R.id.deletbox)).isChecked();
//Write1("*192.16834.0.1405:88839@ok^avvali$rele1#" + "*192.168.0.105:8889@ok^dovomi$rele2#" + "*192.168.1.9:12@no^seeee$rele3#");
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
listItems);
setListAdapter(adapter);
//listItems.add("New Item");
adapter.notifyDataSetChanged();
//loadlist();
CODE : TabActivity (Home) Code that Gives Error :
This code works fine with other ActionBar Activity Forms
try {
spec = tabHost.newTabSpec("list"); // Create a new TabSpec using tab host
spec.setIndicator("LIST"); // set the “LIST” as an indicator
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent(this, List1.class);
spec.setContent(intent);
tabHost.addTab(spec);
}catch (Exception e){
Toast.makeText(getApplicationContext(), "1:"+e.toString(), Toast.LENGTH_LONG).show();
}
// Do the same for the other tabs
it always Toast
1:java.lang.RuntimeException: Unable to start activity Componentinfo{com.example.discopc.myapp/com.example.discopc.myapp.List1}: java.lang.RuntimeException: your content must have a ListView Whose Id attribute is 'android.R.id.list'
HTML : of list activity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="List"
android:id="@+id/textView"
android:layout_centerHorizontal="true"
android:theme="@style/Base.TextAppearance.AppCompat.Widget.ActionBar.Title"
android:textSize="@dimen/abc_action_button_min_width_overflow_material"
android:textStyle="normal" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/textView2" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:longClickable="true">
</ListView>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:id="@+id/deletbox"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:nestedScrollingEnabled="false"
android:enabled="true"
android:checked="false" />
</LinearLayout>
Note :
List1 , extend ListActivity
Home , extends TabActivity
Its not a problem of Tabs cause it work fine with my other forms
Question : How to use SplashScreen and Tab View with a Listview ?