android - Customizing List View -
i new android development , using big nerd ranch guide me learn android development. playing around list's via array adapters , want customize how list looks.
i want list view card style ui have tried far has prevented me doing so. able card style ui event when user digs list , have pasted code below. unable list card style ui
here xml event looks card style ui:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:divider="#00000000" android:dividerheight="25dip" android:paddingtop="25dp" android:paddingleft="16.0dp" android:paddingright="16.0dp" android:layout_marginleft="16dp" android:layout_marginright="16dp" android:layout_margintop="16dp" android:cliptopadding="false" android:background="@drawable/card" > <textview android:id="@+id/event_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="4dp" android:textsize="30dp" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/category_label" android:textcolor="#808080" android:layout_marginleft="4dp" android:layout_marginright="4dp" style="?android:listseparatortextviewstyle" /> <textview android:id="@+id/header1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="16dp" android:layout_marginright="16dp" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:textcolor="#808080" android:layout_marginleft="4dp" android:layout_marginright="4dp" style="?android:listseparatortextviewstyle" /> <textview android:id="@+id/header2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="16dp" android:layout_marginright="16dp" /> <button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="16dp" android:layout_marginright="16dp" android:color="#eeeeee" /> </linearlayout>
i using source code simple_list_item_1 (so can play around code if necessary) , using xml define each item in list:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/card" android:layout_marginleft="45dp" > <imageview android:id="@+id/calendar_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_alignparentright="true" android:enabled="false" android:focusable="false" android:padding="4dp"/> <textview android:id="@+id/crime_list_item_titletextview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_toleftof="@id/calendar_arrow" android:paddingtop="9dp" android:textstyle="bold" android:paddingleft="4dp" android:paddingright="4dp" android:layout_marginleft="4dp" android:layout_marginright="4dp" android:text="crime title"/> " </relativelayout>
here code adapter:
private class crimeadapter extends arrayadapter<crime> { public crimeadapter(arraylist<crime> crimes) { super(getactivity(), r.layout.list_layout, crimes); } @override public view getview(int position, view convertview, viewgroup parent) { // if weren't given view, inflate 1 if (null == convertview) { convertview = getactivity().getlayoutinflater() .inflate(r.layout.list_item_crime, null); // r.layout.list_item_crime same r.android.simple_list_item1 source code if need change can }
how can listview event?
Comments
Post a Comment