0

In my application,i have a custom listview(it contains imageView,two textviews).I am using OnTouch Lisener for touch on listview i open paticular image with full screen and when i release that image in ACTION_Up method. All worked fine but i can't get list item position.Please can any one tell me how to get the postion fo the listview for OnTouch.

Thanks in Advance.

seenu
  • 147
  • 1
  • 7
  • For a question to be answerable, the problem must be reproducible. Please include [minimal sample code](http://sscce.org/): complete, concise and representative. Read [Writing the Perfect Queston](http://tinyurl.com/so-hints/) for more guidelines. – outis Apr 19 '14 at 21:52

2 Answers2

1

Use onItemClickListener for get list item and item's position

Lia Pronina
  • 766
  • 3
  • 7
0

Try OnItemClickListener for your listview..

listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

              // here **position** will give the selected list item position
            }
        });

You can also implement onTouchListener for listview along with onItemClickListener in same activity like this:

listView.setOnTouchListener(new ListView.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int action = event.getAction();
                switch (action) {
                case MotionEvent.ACTION_DOWN:

                     //action down          
                    break;

                case MotionEvent.ACTION_UP:
                    // action up
                    break;
                }

                // Handle ListView touch events.
                v.onTouchEvent(event);
                return true;
            }
        });
Hariharan
  • 24,741
  • 6
  • 50
  • 54