नमस्ते मुझे अपनी सूचीदृश्य में एक इशारा जोड़ना है, मैं संपर्क अनुप्रयोग की समान कार्यक्षमता को कार्यान्वित करना चाहता हूं। जब मैंने स्वाइप छोड़ा तो उसे एक संदेश भेजना चाहिए, इसे स्वाइप करना चाहिए इसे कॉल करना चाहिए। क्या कोई मेरी मदद कर सकता है कि उन इशारा पहचान कैसे करें ... मैंने इसे कई अन्य विचारों में लागू किया है ... लेकिन मैं सूची दृश्य के लिए नहीं कर सका ... मैं क्या नहीं कर रहा हूं ... मेरा कोड `सूचीदृश्य एंड्रॉइड में इशारा
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "Linux", "Windows7", "Eclipse", "Suse", "Ubuntu", "Solaris", "Android", "iPhone"};
// Create an ArrayAdapter, that will actually make the Strings above
// appear in the ListView
this.setListAdapter(new ArrayAdapter<String>(this, R.id.MyList, names));
gestureListener = new ListView.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}
return false;
}
};
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG).show();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (gestureDetector.onTouchEvent(event))
return true;
else
return false;
}
class MyGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
return false;
// right to left swipe
}
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Context ctx = getApplicationContext();
CharSequence txt = "Right to Left Swipe";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(ctx, txt, duration);
toast.show();
Toast.makeText(this.getItem(lv.pointToPosition((int)e1.getX(),(int) e1.getY())));
// return super.onFling();
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Context ctx = getApplicationContext();
CharSequence txt = "Left to Right Swipe";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(ctx, txt, duration);
toast.show();
}
} catch (Exception e) {
// nothing
}
return false;
}
}
[कैसे लागू करने के लिए फ़्लिंग के संभावित डुप्लिकेट एंड्रॉइड लिस्टव्यू में] (http://stackoverflow.com/questions/4030389/how-to-implement-fling-in-android-listview) –