lucasr/twoway-view

setSelection() programmatically , highlighting selectedItem

NabilNoaman opened this issue · 0 comments

Hi ,

Thanks for nice library .

I have two questions

  1. Regarding setSelection() programmatically , I set selected item as shown below but when i use floorsLV.getSelectedView() return null.
ArrayAdapter<String> aItems = new ArrayAdapter<String>(this, R.layout.floor_list_item, floorsName);
        floorsLV = (TwoWayView) findViewById(R.id.floorsLV);
        floorsLV.setAdapter(aItems);
        floorsLV.setItemMargin(70);
        floorsLV.setOrientation(TwoWayView.Orientation.HORIZONTAL);
        floorsLV.setSelected(true);
        floorsLV.setSelector(R.color.floorsSelection);
        Log.i(TAG , "------floor.getIndex()-------:"+floor.getIndex());
        floorsLV.setSelection(floor.getIndex());
  1. Selecting item manually work fine & highlighting selected item. but i want to customise setSelector to be in buttom of selected item instead overlapping whole item. as stated " List selector support (draw on top and under children)" here https://plus.google.com/+LucasRocha/posts/3r4gtgf8umw

My Layout defined as next

    <FrameLayout
        android:id="@+id/floorsContainer"
        android:layout_width="match_parent"
        android:background="@color/floorsBackground"
        android:layout_height="44dp"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="1dp"
        android:layout_marginBottom="1dp">

        <org.lucasr.twowayview.TwoWayView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/floorsLV"
            style="@style/TwoWayView"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:drawSelectorOnTop="false"
            tools:context=".MainActivity"
            android:layout_gravity="center_horizontal"/>
    </FrameLayout>

floor_list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:gravity="center_vertical"
    android:layout_centerInParent="true"
    android:text="Floor X"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    />

Thanks
Nabil