Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>first of all it would be easier if you define your layouts in XML instead of adding them programmatically. You will profit from the benefits of the UI editor as well. :)</p> <p>Second, you may want to use ListView and an Adapter to fill the list, since you do not want do duplicate the same tasks for each layout.</p> <p>Maybe these two links are helpful: 1. <a href="http://developer.android.com/guide/topics/ui/declaring-layout.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/ui/declaring-layout.html</a> 2. <a href="http://developer.android.com/guide/topics/ui/layout/listview.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/ui/layout/listview.html</a></p> <p>So, to finally answer your question, I would do the following:</p> <ul> <li><p>Create a file, e.g. list_item.xml, with something like:</p> <pre><code>&lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp"&gt;&lt;TextView your attributes.../&gt;&lt;/LinearLayout&gt; </code></pre></li> <li><p>Create another layout, for instance main.xml, which contains a ListView. You can change the color of the divider like described here <a href="https://stackoverflow.com/questions/6544723/how-to-change-the-divider-color-in-the-listview">How to change the divider color in the listview?</a>.</p></li> <li><p>In your code (activity or fragment) add the main.xml as content view via setContentView().</p></li> <li><p>Also in your code you should then add an adapter to the ListView which then populates the list for you. Here is an example <a href="https://stackoverflow.com/questions/16333754/how-to-customize-listview-using-baseadapter">How to customize listview using baseadapter</a></p></li> </ul> <p>Finally, and since you separate the concerns (design and code), you could achieve what you want with just a few lines in your activity (the layout stuff would be in the xml and the population could be moved to a separated class like MyAdapter.java...)</p> <p>Hope that helps...</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