Jack, thanks in advance.

How should I declare listview ?
See the code below. It works fine if I'm extending a ListActivity.
Like this:

// ListActivity works
// ------------------
public class FormGrid extends ListActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                setContentView(R.layout.grid);

        ArrayList<String> List = new ArrayList<String>();

        List.add("row 1");
        List.add("row 2");

        setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, List));
        }
}


But I would like to have both ListView and TabHost in the same
activity. So I'm trying thi way:

// ListActivity doesn't work
// -------------------------
public class FormGrid extends TabActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                setContentView(R.layout.grid);

        ListView lv = new ListView(this);
        ArrayList<String> List = new ArrayList<String>();

        List.add("row 1");
        List.add("row 2");

        lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, List));
        }
}

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android";
android:id="@+id/LinearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
        <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </ListView>
</LinearLayout>


On 10 ago, 21:09, Jack Ha <[email protected]> wrote:
>     listview.setAdapter(new MyListAdapter(this));
>
> --
> Jack Ha
> Open Source Development Center
> ・T・ ・ ・Mobile・ stick together
>
> The views, opinions and statements in this email are those of
> the author solely in their individual capacity, and do not
> necessarily represent those of T-Mobile USA, Inc.
>
> On Aug 10, 4:13 pm, Anderson Franco <[email protected]> wrote:
>
> > > You don't need to use ListActivity; just put a ListView in your layout and
> > > work with it directly.
>
> > Ok, I know that. And how can I set a ListAdapter to this view since I
> > am not "extending" ListActivity ?
>
> > Anderson
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to