public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.ok);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText et = (EditText) findViewById(R.id.entry);
Toast.makeText(HelloWorld.this, "You typed: " +
et.getText(), Toast.LENGTH_SHORT).show();
et.bringToFront();
}
});
ListView lv = (ListView) findViewById(R.id.list);
lv.setAdapter(new ArrayAdapter<String>(HelloWorld.this,
R.id.list, R.array.strarr));
lv.setTextFilterEnabled(true);
}
On Aug 6, 12:28 am, Nithin <[email protected]> wrote:
> Are you setting adapter for the listView.
>
> Nithin
>
> On Aug 6, 12:35 am, Warrior <[email protected]> wrote:
>
> > Hi am trying to add a List view as below. But the list never appears.
>
> > <?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:layout_width="fill_parent"
> > android:layout_height="wrap_content"
> > android:text="@string/hello"
> > />
> > <EditText
> > android:id="@+id/entry"
> > android:layout_width="fill_parent"
> > android:layout_height="wrap_content"
> > android:background="@android:drawable/editbox_background"
> > />
> > <ListView
> > android:id="@+id/list"
> > android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> > android:layout_below="@id/entry"
> > android:entries="@array/strarr"
> > android:dividerHeight="14.5sp"
> > />
> > <Button
> > android:id="@+id/ok"
> > android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> > android:layout_below="@id/list"
> > android:layout_alignParentRight="true"
> > android:layout_marginLeft="10dip"
> > android:text="Add to List" />
>
> > </LinearLayout>
>
> > What am I doing wrong?
--
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