Note that there are some explanatory texts on larger screens.

plurals
  1. POCustomizing List View
    primarykey
    data
    text
    <p>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.</p> <p>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</p> <p>Here is the xml for the event that looks like the card style UI:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;TextView android:id="@+id/event_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:textSize="30dp" /&gt; &lt;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" /&gt; &lt;TextView android:id="@+id/header1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" /&gt; &lt;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" /&gt; &lt;TextView android:id="@+id/header2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" /&gt; &lt;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" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>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:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;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"/&gt; &lt;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"/&gt; " &lt;/RelativeLayout&gt; </code></pre> <p>Here is the code for my adapter:</p> <pre><code> private class CrimeAdapter extends ArrayAdapter&lt;Crime&gt; { public CrimeAdapter(ArrayList&lt;Crime&gt; 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 } </code></pre> <p>How can I get my listview to look like the event?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload