0

I have an already established activity that must extend another activity so I'd much rather use commonsware drag and drop TouchListView class with my existing activity rather than extend ListActivity. However, I can't find an example of how to do this. In my activity's xml I have included:

<com.test.dragdrop.TouchListView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tlv="http://schemas.android.com/apk/res/com.test.activities" 
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:drawSelectorOnTop="false"
            tlv:normal_height="64dip"
            tlv:expanded_height="128dip"
            tlv:grabber="@+id/icon"
            tlv:remove_mode="slideRight"
                    android:layout_centerHorizontal="true" 
                    android:layout_centerVertical="true" 
                    android:layout_below="@id/menu_bar_top_include"
                    android:layout_above="@id/footerbar_lists"
                    android:cacheColorHint="#0000" 
                    android:paddingTop="2dip"/>

Now, I'm not sure how translate this to creating it dynamically in my actvities code . I assume I have to place the code in onCreate() and create a RelativeLayout wrapper and put the TouchListView class inside of it, but again I'm not sure when it comes to a custom view class... any one do this before?

Note: I also tried to simply use :

TouchListView tlv = (TouchListView) findViewById(R.id.list);

but I get compiler errors:
--- for some reason the compiler cannot find "R.id.list" --- Is this because its inside a custom view? Is there some other way this needs to be specified?

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Mike6679
  • 5,547
  • 19
  • 63
  • 108

1 Answers1

1

There is nothing different about using TouchListView in a regular Activity than using ListView in a regular Activity. All you do is call findViewById() to get the ListView and call setAdapter() on the ListView to associate your desired ListAdapter with it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks fo the response. Yes, that what I tried to do but I get compiler errors: TouchListView tlv = (TouchListView) findViewById(R.id.list); --- for some reason the compiler cannot find "R.id.list" --- Is this because its inside a custom view? Is there some other way this needs to be specified? – Mike6679 Jan 05 '12 at 16:18
  • @Mike: Then update your question and provide your compiler errors. – CommonsWare Jan 05 '12 at 16:20
  • I'm open to any suggestions at this point whether it be getting findViewById() to work OR creating an instance of TouchListView and setting all the parameters dynamically -thanks. – Mike6679 Jan 05 '12 at 22:38
  • @Mike: Use `android.R.id.list` instead of `R.id.list`. – CommonsWare Jan 05 '12 at 23:07