Code example for ArrayAdapter

Methods: addgetCount, getPosition

0
            mIitc.getWebView().loadUrl(
                    "javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");");
    } 
 
    public void addPortalHighlighter(String name) {
        mHighlighters.add(name);
 
        // to select active highlighter. must be called every time because of sorting 
        setActiveHighlighter(mActiveHighlighter);
    } 
 
    public void onBootFinished() { 
        mLoading = false;
        updateLayers(); 
    } 
 
    @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
            item.active = active;
            setLayer(item);
        } 
 
        mOverlayLayers.notifyDataSetChanged();
 
        return true; 
    } 
 
    @Override 
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        if (mLoading) return;
 
        if (parent.equals(mSpinnerHighlighter)) {
            String name = mHighlighters.getItem(position);
            mIitc.getWebView().loadUrl("javascript: window.changePortalHighlights('" + name + "')");
        } 
        else if (parent.equals(mSpinnerBaseMap)) {
            mBaseLayers.getItem(mActiveLayer).active = false; // set old layer to hidden, but no need to really hide
 
            Layer layer = mBaseLayers.getItem(position);
            layer.active = true;
            setLayer(layer);
        } 
    } 
 
    @Override 
    public void onNothingSelected(AdapterView<?> parent) {
        // ignore 
    } 
 
    public void reset() { 
        mHighlighters.clear();
        mBaseLayers.clear();
        mOverlayLayers.clear();
 
        mIitc.getNavigationHelper().setHighlighter(null);
 
        mLoading = true;
    } 
 
    public void setActiveHighlighter(String name) {
        mActiveHighlighter = name;
 
        int position = mHighlighters.getPosition(mActiveHighlighter);
        if (position >= 0 && position < mHighlighters.getCount())
            mSpinnerHighlighter.setSelection(position);
 
        mIitc.getNavigationHelper().setHighlighter(name);
    }