Ok thanks So I try to us ListActivity

I try to play your simple code here:

*******************************************************************************************************************
public class MyActivity extends ListActivity {

        public TextView selection;
        public  String[] mStrings = new String[] {"item0", "item1", "item2",
"item3", "item4" };

        @Override
        protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                selection=(TextView)findViewById(R.id.label);

                ArrayAdapter<String> mAdapter = new ArrayAdapter<String>
(this,R.layout.main, R.id.label, mStrings);

                setListAdapter(mAdapter);
        }

        public void onListItemClick(ListView parent, View v,
                        int position, long id) {
                        selection.setText(mStrings[position]);
                        }
}
********************************************************************************************************************************************************

And 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="wrap_content"
        android:orientation="horizontal"
        >
        <ImageView
                android:id="@+id/icon"
                android:layout_width="22px"
                android:paddingLeft="2px"
                android:paddingRight="2px"
                android:paddingTop="2px"
                android:layout_height="wrap_content"
                android:src="@drawable/check32"
        />
        <TextView
                android:id="@+id/label"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="44sp"
        />
</LinearLayout>
***********************************************************************************************************************************************************

But there is an exception error like this:

08-10 14:25:43.851: ERROR/AndroidRuntime(1643):
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.dany.android.listtestandroid/
com.dany.android.listtestandroid.MyActivity}:
java.lang.RuntimeException: Your content must have a ListView whose id
attribute is 'android.R.id.list'


I thought That i just need to us textView and not listview.

dany






On Aug 10, 3:50 pm, Mark Murphy <[email protected]> wrote:
> Dany BREARD wrote:
> > I think I have 2 methode:
>
> > - Take my list(icon+text) with my class extends ListActivity without
> > buttons and i will find a methode to add my button later
>
> > - Or conitnuous my code that i made with buttons and my class extends
> > Acitvity and find a methode to add icon for each String.
>
> You can have buttons at the bottom of the activity in a ListActivity.
> Just put them in your layout and use setContentView() like you would any
> other activity.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android 1.5 Programming Books:http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
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