Code example for ArrayAdapter

Methods: getItemnotifyDataSetChanged

0
 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        position--; // The ListView header counts as an item as well.
 
        Layer item = mOverlayLayers.getItem(position);
        item.active = !item.active;
        setLayer(item);
        mOverlayLayers.notifyDataSetChanged();
    } 
 
    @Override 
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        position--; // The ListView header counts as an item as well.
        boolean active = !mOverlayLayers.getItem(position).active;
 
        for (int i = 0; i < mOverlayLayers.getCount(); i++) {
            Layer item = mOverlayLayers.getItem(i);
            if (item.name.contains("DEBUG")) continue;
            if (active == item.active) continue; // no need to set same value again
Connect your IDE to all the code out there  Get Codota for Java