Creating custom style of ListViewItem

Hi all,
I'm new to working with Xamarin and mobile development.
I have wrote a C# library, which get information from web-site and return it in List format, each instance of have many properties.
Now I want to display this list in the multiselected ListView like it looks on pictures in attachment.
In normal state ListViewItem left top icons must change depending on property of , in selected state it's icon must hide.
Please give me advice how can i do it.
I was wondering if you show me a simple sample.
Thanks

Posts

  • CheesebaronCheesebaron DKInsider, University mod

    Maybe this can get you going:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_margin="5dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:src="@drawable/Icon"
            android:id="@+id/tropy_image"
            android:layout_height="25dp"
            android:layout_width="25dp"
            android:layout_alignParentTop="true"
            android:layout_alingParentLeft="true" />
        <ImageView
            android:src="@drawable/Icon"
            android:id="@+id/heart_image"
            android:layout_height="25dp"
            android:layout_width="25dp"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/tropy_image" />
        <TextView
            android:id="@+id/itemid_text"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_toRightOf="@+id/heart_image"
            android:text="31400812993" />
        <TextView
            android:id="@+id/percent_text"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:text="/ 3,5%" />
        <TextView
            android:id="@+id/number_text"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_toLeftOf="@+id/percent_text"
            android:text="52 000 012,00 " />
        <TextView
            android:id="@+id/description_text"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_below="@+id/tropy_image"
            android:maxLines="4"
            android:text="Bacon ipsum dolor sit amet porchetta beef ribs tail kielbasa. Cow jerky biltong, fatback salami bresaola ham rump ham hock. Jerky doner cow, landjaeger prosciutto ham hock chuck brisket bacon porchetta. Kielbasa doner rump sausage, frankfurter brisket hamburger bacon shankle prosciutto chuck turkey capicola pastrami pig. Prosciutto corned beef chuck doner tail cow pork loin pastrami pork kevin swine tenderloin. Short ribs frankfurter t-bone, salami hamburger tri-tip pancetta meatball sausage."
            android:ellipsize="end"
            android:layout_marginRight="30dp" />
        <ImageView
            android:src="@drawable/Icon"
            android:id="@+id/doc_image"
            android:layout_height="25dp"
            android:layout_width="25dp"
            android:layout_below="@+id/percent_text"
            android:layout_alignParentRight="true" />
    </RelativeLayout>
    

    Use that as a list item which you inflate in your adapter and populate each of the views with the data from your web service.

    More on ListViews and Adapters here: http://docs.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters/

Sign In or Register to comment.