0

I have created one ListView by defining ListView lv=new ListView(this) in one of my activity.I have a Array of Strings which i want to add to this listview.How can i define a list adapter for this listview? Anyone having any idea? Can we create ListView like this as i mentioned above.Because it will show error "Your activity must have a listview with id android.R.id.list.

1
  • This link may help you. Commented Aug 20, 2011 at 5:31

1 Answer 1

1

You need to define ListView in xml like this

<ListView 
 android:id="@android:id/list"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content">
 </ListView>

This would resolve your error message.

You can have a nice tutorial for ListView and ListActivity here.

ListView & ListActivity

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.