एडाप्टर वर्ग के रूप में इस प्रकार के बूलियन चर टचडाउन और touchup जोड़ना काफी अच्छी तरह से काम करने के लिए लगता है:
private class MyListAdapter extends ArrayAdapter<MyObject>{
...
//touch down + touch up with no other motion events in between = click
boolean touchDown = false;
boolean touchUp = false;
private int iHostViewID;
...
public MyListAdapter(Context context,int viewResourceId, List<MyObject> objects) {
super(context, textViewResourceId, objects);
iHostViewID = viewResourceId;
}
@Override
public View getView(int pos, View convertView, ViewGroup parent){
View itemView = convertView;
//iff we cannot re-use a view
if(itemView == null){
LayoutInflater inflater = (
(LayoutInflater)hContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
itemView = inflater.inflate(iHostViewID, null);
}
final View hItemView = itemView;
final int hPosition = pos;
...
final HorizontalScrollView textDataSV =
(HorizontalScrollView)itemView.findViewById(R.id.widget_hsv);
textDataSV.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
touchDown = true;
}
else if(event.getAction() == MotionEvent.ACTION_UP){
touchUp = true;
}
else{
touchDown = false;
touchUp = false;
}
if(touchDown && touchUp){
//click
//mMyListView is the reference to the list view
//instantiated in the view controller class responsible
//for setting this adapter class as the list view's adapter
mMyListView.performItemClick(hItemView, hPosition,
hItemView.getId());
}
return false;
}
});
}
}
यह सही कतई नहीं है, लेकिन अधिकांश मानक उपयोग-मामले
लिए काम करना चाहिए कृपया कोशिश करें ब्लॉग surroung listview पर क्लिक करें लॉग इन करें और लॉग में प्रिंट त्रुटि और यहां अपनी त्रुटि पोस्ट करें ताकि हम जान सकें कि क्या गलत हो रहा है। – Aamirkhan
मुझे कोई त्रुटि नहीं है ... समस्या इस विचार के व्यवहार के साथ करना है क्योंकि वे इस तरह से सेटअप हैं। – startupsmith
ठीक है क्या आप अपनी एक्सएमएल फाइल पोस्ट कर सकते हैं जिसे आप कस्टम एडैपर के रूप में उपयोग कर रहे हैं? – Aamirkhan