Android.widget.arrayadapter Just Accept Row Template
I am developing an android application which contains a ListAtivity class and get it is data as follow : ArrayAdapter- ara=new MyArrayAdapter(this,_items); setListAdapt
Solution 1:
If you want a different layout than a simple ListView
you have the option of setting the content view to a layout file like this:
setContentView(R.layout.layout_with_diferrent_views); // call this on the onCreate() method
where R.layout.layout_with_different_views
could be a xml layout like this:
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="TextView" /><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button" /><ListViewandroid:id="@android:id/list"android:layout_width="fill_parent"android:layout_height="wrap_content" ></ListView></LinearLayout>
Because you extends ListActivity
you must have in the layout a ListView
element with the id @android:id/list
. Of course you can have a more complex layout than the one above as long as you have a ListView
element with the id @android:id/list
Solution 2:
You should consider using a listHeader : lv.addHeaderView(findViewById(R.id.header)); This has to be done in your onCreate method in your activity, and you must provide a widget with the id header.
Solution 3:
If you want other components in activity.Then better consider Normal Activity instead ListActivity.
Post a Comment for "Android.widget.arrayadapter Just Accept Row Template"