I am new to android development and I am using the Big Nerd Ranch guide to help me learn android development. I am playing around with list's via array adapters and I want to customize how my list looks.
I want my list view to also look like the card style UI but everything I have tried so far has prevented me from doing so. I am able to get the card style UI for the event when the user digs into the list and I have pasted that code below. But I am unable to get the list to look like the card style UI
Here is the xml for the event that looks like the 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 am using the source code for simple_list_item_1 (so I can play around with the code if necessary) and I am then using this xml to define each item in the 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 is the code for my 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 we weren't given a view, inflate one
if (null == convertView) {
convertView = getActivity().getLayoutInflater()
.inflate(R.layout.list_item_crime, null);
// R.layout.list_item_crime is the same as R.android.simple_list_item1 its just the source code so if I need to change it I can
}
How can I get my listview to look like the event?