<span id="Label3"></p><p><p><br></p></p><p><p><span style="font-size:18px;">recently do a black ant temperature control system project, There are many list items, but when used, feel the package is already very good, I took it to change the code on the line, so after the use of no feeling. Now in the spare time to tidy up the simple listview, the experience of this thing in the end is how a principle. </span></p></p><p><p><br></p></p><p><p><span style="font-size:18px;">First look at the implementation effect:</span></p></p><p><p><br></p></p> <blockquote> <blockquote> <blockquote> <blockquote> <blockquote> <blockquote> <p><span style="font-size:18px;"></span></p> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote><p><p><span style="font-size:18px;">Each list item adds an image followed by a textview, and the data source is bound to the TEXTVIEW.</span></p></p><p><p><span style="font-size:18px;"><br></span></p></p><p><p><span style="font-size:18px;">first, Add two layout files:</span></p></p><p><p><br></p></p><p><p><span style="font-size:18px;">Layout file for list (item):</span></p></p><p><p><span style="font-size:18px;"></span></p></p><pre name="code" class="html"><pre name="code" class="html"><span style="font-size:12px;"><?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=" match_parent " android:o rientation= "horizontal" > <imageview android:layout_width= "wrap_content" android:layout_ height= "wrap_content" android:src= "@drawable/ic_launcher" /> <textview android:id= "@ +id/name " android:layout_width=" wrap_content " android:layout_height=" wrap_content " android:text = "lhc" /></linearlayout></span></pre></pre><p><p></p></p><p><p><span style="font-size:18px;"><br></span></p></p><p><p><span style="font-size:18px;">This is followed by the entire activity layout file:</span></p></p><p><p><span style="font-size:18px;"></span></p></p><pre name="code" class="html"><pre name="code" class="html"><span style="font-size:12px;"><?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=" match_parent " android:o rientation= "vertical" > <listview android:id= "@+id/lv" android:layout_width= "wrap_content" android:layout_height= "wrap_content" /></linearlayout></span></pre></pre><p><p></p></p><p><p><br></p></p><p><p><span style="font-size:18px;"><br></span></p></p><p><p><span style="font-size:18px;">Next is the activity code:</span></p></p><p><p><br></p></p><p><p> <span style="font-size:18px;"> <br> </span> </p> </p><pre name="code" class="java"><span style="font-size:12px;">public class Listdemo extends activity{private string[] names;//analog data source Private arraylist
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service