Multiple selection with API 10

4 posts, 0 answers
  1. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 28 May 2015 Link to this post

    I have implemented multiple selection with android:background="@drawable/selectable_item_background"/> and it works fine on higher APIs, but on API 10 it is not distinguishable between selected and non selected rows. They look just the same.

    How do I get it to work on API 10

  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 28 May 2015 Link to this post

    Hi Alexander,

    Thank you for writing.

    As stated in this documentation article, the state list drawable (which selectable_item_backgroud is) need to be set to the root element of your layout in order to target all platforms, a condition which is no longer a requirement since API 11. So in order to make it work on API 10, you need to change your layout (or provide another only for API 10) which complies with this requirement.

    I hope this information helps.

    Regards,
    Todor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 28 May 2015 in reply to Todor Link to this post

    Yes, and I have exactly as in the article you linked, set to the root element.

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"<br>    android:layout_width="match_parent"<br>    android:layout_height="match_parent"><br>    <LinearLayout<br>        android:layout_width="match_parent"<br>        android:layout_height="match_parent"<br>        android:orientation="vertical"<br>        android:background="@drawable/pressable_item_background"<br>        android:padding="16dp"><br>        <TextView<br>            android:id="@+id/nameView"<br>            android:layout_width="match_parent"<br>            android:layout_height="wrap_content"<br>            android:textSize="16sp"<br>            android:textColor="#FF33B5E5" /><br>        <TextView<br>            android:id="@+id/countryView"<br>            android:layout_width="match_parent"<br>            android:layout_height="wrap_content"<br>            android:textSize="14sp"<br>            android:textColor="#8A000000" /><br>    </LinearLayout><br>    <View<br>        android:layout_width="match_parent"<br>        android:layout_height="match_parent"<br>        android:background="@drawable/selectable_item_background"/><br></FrameLayout>
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 02 Jun 2015 Link to this post

    Hello Aleksandar,

    By root element, I meant the first layout in your resource - in that case - FrameLayout. The code that you have is the layout file that works since API 11, so you can save it in a folder named layout-v11 in your project so that it is used only for these versions. Additionally, in order to make the selection work prior to API 11, you should create a file with the same name in the layout folder of your project and use this sample content:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@drawable/gingerbread_background"
        android:padding="16dp">
            <TextView
            android:id="@+id/nameView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="16sp"
            android:textColor="#FF33B5E5" />
        <TextView
           android:id="@+id/countryView"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:textSize="14sp"
           android:textColor="#8A000000" />
    </LinearLayout>

    In this case the root element is the LinearLayout and as you can see it has its background set to a state list drawable (this time gingerbread_background, but selectable_item_background should have similar effect).

    I hope this information helps.

    Regards,
    Todor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner