enviroCar / enviroCar-app

enviroCar Android Application
https://envirocar.org
GNU General Public License v3.0
90 stars 158 forks source link

How to select an item with a long click? #24

Closed jakobmoellers closed 11 years ago

jakobmoellers commented 11 years ago

You can implement the following:

elv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            Log.e("obd2", String.valueOf("Position " + arg2));
            return false;
        }

    });

The problem is: the position is different when the item is expanded or not! So if you extend an item, the next one will have a position that is increased by 1. Can we omit that?

This is crucial to select items, edit tracks and start the map view with the correct track!

dwilhelm89 commented 11 years ago

This should be possible with a SimpleExpandableListAdapter: http://developer.android.com/reference/android/widget/ExpandableListView.OnGroupClickListener.html

jakobmoellers commented 11 years ago

Okay @dwilhelm89 found the solution. Thanks! I will implement the long click to edit, upload and delete single tracks tomorrow or so. This might also be interesting for the map... maybe we can also start the map view with the long click. @ChristopherStephan what do you think about that?

jakobmoellers commented 11 years ago

fixed d5a3e5767a2f37b02ed0524f23b40ed9327c88a3