I have a huge problem with making touchable listview. I tried 200 solutions without results. The most logical for me is something like this:
SomeActivity.java
Using java Syntax Highlighting
- public class SomeActivity extends ListActivity
- {
- protected void onCreate(Bundle icicle)
- {
- super.onCreate(icicle);
- TouchList tl = new TouchList(this);
- LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
- tl.setLayoutParams(lp);
- LinearLayout currentLay = (LinearLayout) findViewById(R.id.some_layout_linear);
- currentLay.addView(tl,0);
- setContentView(R.layout.some_layout);
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
TouchList
Using java Syntax Highlighting
- public class TouchList extends ListView
- {
- public TouchList(Context context) {
- super(context);
- this.setId(android.R.id.list);
- this.setFocusable(true);
- this.setFocusableInTouchMode(true);
- }
- public boolean onTouchEvent(MotionEvent event)
- {
- // some code here
- }
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
some_layout.xml
Using xml Syntax Highlighting
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/some_layout_linear"
- >
- <TextView
- android:id="@android:id/empty"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:text="No items"
- />
- </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
And of course it doesn't wok - there are a couple errors in first class - the best will be if someone can simply run it on own emulator and see - because is hard to write some more informations about errors.
In example above I'm trying to create listview with "list" id and then add it on first (0) position of linearlayout, which exists in xml file. A tried also couple other ways, but without good result - can You help me?
All I want to do is access to "onTouchEvent" of listview in ListActivity.
Thank You for any help.

