Hi Man,

Create new workspace ..copy paste the code then run and check it.



On Fri, Jun 10, 2011 at 3:57 PM, tekinoypi <akoto1...@gmail.com> wrote:

> I copied and paste the ListViewDemo codes from the book Beginning
> Android 2, page 61.
>
> There are no errors in Eclipse, BUT when it is executed in Android 2.1
> & Android 2.2 emulators the application displays a pop-up for a
> problem or crashes instantly.
>
> I am a beginner in Android Development, any help regarding this issue
> would be greatly appreciated. Thank you!
>
> FILENAME: ListViewDemo.java
>
> package com.commonsware.android.list;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.app.ListActivity;
> import android.view.View;
> import android.widget.AdapterView;
> import android.widget.ArrayAdapter;
> import android.widget.ListView;
> import android.widget.TextView;
>
> public class ListViewDemo extends ListActivity {
>        TextView selection;
>        String[] items={"lorem", "ipsum", "dolor", "sit", "amet",
>                                        "consectetuer", "adipiscing",
> "elit", "morbi", "vel",
>                                        "ligula", "vitae", "arcu",
> "aliquet", "mollis",
>                                        "etiam", "vel", "erat", "placerat",
> "ante",
>                                        "porttitor", "sodales",
> "pellentesque", "augue", "purus"};
>
>        @Override
>        public void onCreate(Bundle icicle) {
>                super.onCreate(icicle);
>                setContentView(R.layout.main);
>                setListAdapter(new ArrayAdapter<String>(this,
> android.R.layout.simple_list_item_1, items));
>                selection=(TextView)findViewById(R.id.selection);
>        }
>
>        public void onListItemClick(ListView parent, View v, int
> position,long id) {
>                selection.setText(items[position]);
>        }
> }
>
> FILENAME: main.xml
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout
>        xmlns:android="http://schemas.android.com/apk/res/android";
>        android:orientation="vertical"
>        android:layout_width="fill_parent"
>        android:layout_height="fill_parent" >
>        <TextView
>                android:id="@+id/selection"
>                android:layout_width="fill_parent"
>                android:layout_height="wrap_content"/>
>        <ListView
>                android:id="@android:id/list"
>                android:layout_width="fill_parent"
>                android:layout_height="fill_parent"
>                android:drawSelectorOnTop="false"
>                />
> </LinearLayout>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en




-- 




"Nobody can go back and start a new beginning, but anyone can start today
and make a new ending"
-----
Thanks,
Regards,
νιנαソαkum@r M
BloG:http://iamvijayakumar.blogspot.com/
Mob.No:09048382536(Kerala)
Mob.No:09751076707(TN)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to