Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the item in listview by touch event in android, so I set background color of that item when I move event on it
    primarykey
    data
    text
    <p>I want to move the figure on list view item that contains phone number.</p> <p>When I move figure from right to left, make a call. I'm failing to get that particoular item in list view to get the phone number and make a call.</p> <p>My code is</p> <pre><code> @Override arg1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { float startX = 0; float startY; float endX; float endY; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startX = (int) event.getX(); startY = (int) event.getY(); System.out.println("startX" + startX); System.out.println("startY" + startY); break; case MotionEvent.ACTION_MOVE: endX = event.getX(); endY = (int) event.getY(); System.out.println("endX" + endX); System.out.println("endY" + endY); float sub = endX - startX; System.out.println("sub" + sub); if ((endX - startX) &lt; 100) { arg0.setBackgroundColor(Color.GREEN); } if ((endX - startX) &gt; 100) { try { TextView ph_tv = (TextView) arg0 .findViewById(R.id.textnum); String Pho_no = ph_tv.getText().toString(); arg0.setBackgroundColor(Color.RED); Intent intent = new Intent( Intent.ACTION_CALL, Uri .parse("tel:" + Pho_no)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); lv.setBackgroundColor(Color.BLACK); } catch (ActivityNotFoundException e) { Toast.makeText( getApplicationContext(), "Error in your phone call" + e.getMessage(), Toast.LENGTH_LONG).show(); } section(path_name, lv1); } break; case MotionEvent.ACTION_UP: endX = (int) event.getX(); endY = (int) event.getY(); } return true; } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload