Check click position on a ListView

4

I have a screen that has ListView inside it, I need to identify which line was clicked to point to the correct location. How can I do this?

    
asked by anonymous 12.09.2016 / 13:47

1 answer

5

You can use the setOnItemClickListener() this way:

listItemView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this, listItemsValue[position], Toast.LENGTH_SHORT).show();
            }
        });

In my case this results in a Toast message on the screen:

Details

Good luck.

    
12.09.2016 / 14:11