I have this class and XML
public class MyClass extends SherlockListActivity implements OnTouchListener
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:smoothScrollbar="true"
android:cacheColorHint="#fff"
android:fastScrollEnabled="false"
android:clickable="true"
android:layout_weight="1"
android:dividerHeight="1sp" />
I'm not able to detect a click. The only way to register a click is to drag. I don't understand what the problem is.
getListView().setOnTouchListener(this);
Here is my onTouch:
public boolean onTouch(View v, MotionEvent event)
{
Log.i("Click", "MAIN");
switch (event.getAction() & MotionEvent.ACTION_MASK)
{
case MotionEvent.ACTION_DOWN:
...
The only way to get any log is (or action) is by dragging. I tried click and long click and none works. Any idea how to fix this and keep onTouch?
Edit: The list view uses a different ArrayAdapter implementation (my own):
public class ContentDisplayListAdapter extends ArrayAdapter<DataContentsInfo> {
private List<DataContentsInfo> items;
private DataContentsInfo o;
public ContentDisplayListAdapter(Context context, int textViewResourceId, List<DataContentsInfo> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.content_display_row, null);
}
o = items.get(position);
if(o != null) {
TextView content = (TextView) v.findViewById(R.id.content);
TextView DataNo = (TextView) v.findViewById(R.id.title_no);
ContentDisplayAdapter.updateTitles(getContext(), o, content, DataNo, items.size());
}
return v;
}
}