Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Setting up ListView with delete button
    primarykey
    data
    text
    <p>There are similar questions out there, but I haven't seen one answer this very direct question: How do you set up a custom listview with a mixture of layouts?</p> <p>I'm trying to set up a list view where each row has the following:</p> <p>A primary text line, a secondary (sub) text line, and a delete button. An alternative to this would be having each row selectable with a delete button at the header or footer of the visible space (but out of the scrollable space, obviously). Honestly whichever is easier at this point is preferable.</p> <p>What I'm left with is setting up a secondary layout xml to define each row element, but inside that I'm looking another layout to separate the button from the vertical orientation of the text layout.</p> <p>Here's my current code:</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="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;ListView android:layout_height="wrap_content" android:layout_width="fill_parent" android:choiceMode="multipleChoice" android:id="@+id/android:list"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>The layout for each row looks like this:</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="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/line_a" android:textSize="14dp" android:textColor="#FFFFFF" android:textStyle="italic" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; &lt;TextView android:id="@+id/line_b" android:textSize="12dp" android:textColor="#BFFF00" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>This sets up a nice multi-colored two-level text for each row in the ListView. </p> <p>So what's next? To add a button on the right hand side I need to set up another layout (grid perhaps? 2 column 1 row?) with a button on the right hand side? Another alternative would be something like wrapping the existing vertical linear layout in another linearlayout with the horizontal orientation, yes?</p> <p>Does this not seem awkward and painful to anyone else? :)</p>
    singulars
    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.
    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