Reputation: 625
I don't know what's going on I first posted this in a class that extends Activity. But even after changing it to a ListActivity it still doesn't work. I'll dumb it down to where I think the problem is.
public class PassScreen extends ListActivity {
String[] items = {"lorem","ipsum", "dolor"};// I have it calling an xml file but switched it to this just to see if that was the problem.
setContentView(R.layout.passwordscreen);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
items));
I don't get what's wrong. This is what my book uses. I checked to make sure the xml file displays the proper ListView and it does. But here it is anyway:
<?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="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="wrap_content"
android:drawSelectorOnTop="false"/>
</LinearLayout>
Upvotes: 1
Views: 4259
Reputation: 625
OK so I just found out the problem. ARGH!! This is why I love programing. My Layout needed an orientation.
So:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
Should have looked like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" // This is the difference.
android:layout_width="fill_parent"
android:layout_height="fill_parent">
Upvotes: 1
Reputation: 33238
try this..
getListView().setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));
getListView().setTextFilterEnabled(true);
Upvotes: 1