host.addTab(host.newTabSpec("Offers")
.setIndicator("Offers", getResources().getDrawable(R.drawable.icon_light))
.setContent(new Intent(this, List_Items.class)));
List_Items.class
public class List_Items extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_item);
} //oncreate
list_item.xml
<?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:id="@+id/textItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:background="#00000000"
android:textColor="#ffffffff"
android:textSize="22sp"
android:text="Find Car"
android:enabled="false"
>
</TextView>
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="5"></ListView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="1.2">
<Button android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:background="@drawable/btn_sync"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true">
</Button>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="0.8">
</RelativeLayout>
So, now I want to change the public class List_Items extends Activity to extends ListActivity because I don’t see the the scrolling action on output. Once I changed to extends ListAcitivity the program crashed. what’s the reason?
From the android documentation:
“ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id “@android:id/list” (or list if it’s in code)”
You don’t have an item with id “list” in your layout.