Dany BREARD wrote:
> 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.

Please re-read the PDF I linked to several messages ago. You can get
source code that matches that excerpt from:

http://commonsware.com/Android

(click on the Source Code link, and look in the FancyLists directory in
the ZIP file)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~
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