在同一个列表项目多TextViews [英] Multiple TextViews in the same List Item

查看:139
本文介绍了在同一个列表项目多TextViews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是的ListView 与阵列适配器上显示多个列表项。我想有多个的TextView 列表中的项目按的的图片

I'm using a ListView with an array adapter to display multiple list items. I'd like to have multiple TextView in the list item as per the picture

我目前使用的线性布局,似乎并不适合...一会相对布局帮助我实现这一目标?

I'm currently using a linear layout which doesn't seem to be suitable... Would a relative layout help me achieve this?

举例code或教程链接会很酷

Example code or tutorial link would be cool

干杯
ListView控件XML

Cheers ListView xml

<?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:orientation="vertical" >

    <ListView
        android:id="@+id/listViewTest"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

ArrayAdapter xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >


    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="89dp"
        android:layout_marginLeft="4px"
        android:layout_marginRight="10px"
        android:layout_marginTop="4px"
        android:layout_weight="0.34"
        android:src="@drawable/ic_launcher" >

    </ImageView>


    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_weight="0.97"
        android:gravity="center"
        android:text="@+id/label"
        android:textSize="30dp" >

    </TextView>

</LinearLayout> 

我试图使用Eclipse图形布局选项卡现有的TextView下添加一个TextView的,但我的noobieness的凑了过来。

I'm trying to add another textView under the existing textView using graphical layout tab in eclipse but my noobieness is getting in the way

推荐答案

此链接使用多个文本在单个列表视图...

This link uses Multiple Texts in a Single Listview...

<一个href=\"http://publicstaticdroidmain.com/2011/12/building-a-custom-multi-line-listview-in-android/\">http://publicstaticdroidmain.com/2011/12/building-a-custom-multi-line-listview-in-android/

使用的code如下。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical|center_horizontal"
    android:text="Custom ListView Example" />

<ListView
    android:id="@+id/srListView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="10dip"
android:paddingLeft="10dip"
android:paddingTop="10dip" >

<TextView
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#C20000"
    android:textSize="14sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/cityState"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/phone"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</LinearLayout>

这篇关于在同一个列表项目多TextViews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆