Android 如何在listview中将布局文本设置为彼此相邻?

Android 如何在listview中将布局文本设置为彼此相邻?,android,android-layout,android-listview,Android,Android Layout,Android Listview,在这里,我希望我的日期在我的头衔旁边,在拉津旁边,在listviev的角落,而不是在头衔下面。我使用了listview的android deafult布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android

在这里,我希望我的日期在我的头衔旁边,在拉津旁边,在listviev的角落,而不是在头衔下面。我使用了listview的android deafult布局

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

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

</LinearLayout>

编辑:我按照你的建议得到了这个,但我想把日期放在角落里


列表视图
项目顶层布局设置为具有“水平”方向的
线性布局
。然后
文本视图
将并排显示

您也可以使用
RelativeLayout
,然后轻松地将每个
TextView
放置在任何位置

默认的
ListView
layout
android.R.layout.simple\u list\u item\u 2
如下所示:

<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:mode="twoLine"
    android:paddingBottom="9dp"
    android:paddingTop="5dp" >

    <TextView
        android:id="@android:id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:textAppearance="?android:attr/textAppearanceListItem" />

    <TextView
        android:id="@android:id/text2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@android:id/text1"
        android:layout_below="@android:id/text1"
        android:textAppearance="?android:attr/textAppearanceSmall" />

</TwoLineListItem>

从这个开始。
要使用“水平”
LinearLayout
,您必须使用“
android:orientation=“horizontal
”将
TwoLineListItem
更改为
LinearLayout
,并添加额外的
TextView


要使用
RelativeLayout
,必须将
TwoLineListItem
更改为
RelativeLayout
,添加额外的
TextView
,并按照您的需要放置它们。

这将是组件。使用Baseadapter将其添加到列表将提供您所需的内容。您可以使用他说,这对你有帮助

    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Title"
        android:textSize="45dp"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="18dp"
        android:text="Sub content"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>


我尝试了oreintation=horizontal,但没有发生任何事情……你能告诉我在哪里可以用xml编辑吗?在你的
res/Layout
目录中的一个新布局文件中编辑xml。但是对于listview,我只有一个上面显示的xml。你需要为列表项提供第二个xml文件。它将由适配器访问,并用于布局每个列表项行。不,我没有任何其他xml,因为我使用了默认的android布局。你可以看到我的代码。可以提供你在listview中添加的布局我认为这可以通过使用相对布局Reedev>>解决。你是说JAVA代码??你如何在listview中添加组件???使用默认的Arrayadapter或使用你自己的适配器?使用database游标适配器自定义baseadapter并使用您自己的组件创建listview将解决您的问题…嘿,您可以在DAVID回答中看到屏幕截图,这就是我得到的,但我希望文本大小为“textAppearanceLarge”“对我来说尺寸不够,应该在角落里设置日期我编辑了我的ans您可以使用此布局制作自定义适配器Hanks伙计们,这很有帮助:)