• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Accessing my ListView

D

Deleted User

Guest
I created an Activity that extends ListActivity
Code:
public class ActivityInbox extends ListActivity implements OnClickListener, StateModelListener {
My layout for this Activity is as follows
Code:
<?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"
    >
    <ListView
    	android:id="@+id/android:list"
    	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
    />
	<TextView
    	android:id="@+id/android:empty"
    	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
    	android:text="@string/inbox_no_items"
    />
</LinearLayout>

I followed a tutorial to do this. As you can see, my ListView's id in the xml is @+id/android:list which seems to be a generic id.

When I am in my Activity's OnCreate handler, I cannot access this ListView object.

Code:
ListView lw = (ListView) findViewById(R.id.???????);

How can I do this? If I edit the layout xml and give it my own custom id, the application crashes when the following line is called in the Activity OnCreate method:
Code:
setContentView(R.layout.layout_inbox);

Is there something like this.????????? that can pull the view? I want to create a context menu for my list items, but I need this in a ListView object
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones