Android:带有图像和文本的搜索结果列表视图

Android:带有图像和文本的搜索结果列表视图,android,android-layout,android-listview,android-linearlayout,android-ui,Android,Android Layout,Android Listview,Android Linearlayout,Android Ui,在我正在开发的android 4.1应用程序中,我希望搜索结果列表视图中的文本显示在缩略图的右侧。我通过解析一个xml文件得到结果。现在,我的文本显示在图像下方,但我希望它显示在图像的右侧 人员搜索列表.xml <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orienta

在我正在开发的android 4.1应用程序中,我希望搜索结果列表视图中的文本显示在缩略图的右侧。我通过解析一个xml文件得到结果。现在,我的文本显示在图像下方,但我希望它显示在图像的右侧

人员搜索列表.xml

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

    <ListView android:id="@android:id/list"
        android:layout_width="fill_parent" android:layout_height="0dip"
        android:layout_weight="1" android:drawSelectorOnTop="false"
        />

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:contentDescription="@string/description"
        android:gravity="left"
        android:scaleType="fitXY" />

        <TextView
        android:id="@+id/empty"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="left"
        android:text="" />

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content">

    <LinearLayout
        android:id="@+id/footer"
        style="@android:style/ButtonBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/prev_10_results"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.14"
            android:text="@string/prev_10_results" />

        <Button
            android:id="@+id/next_10_results"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="@string/next_10_results" />
    </LinearLayout>

    </ScrollView>

    </LinearLayout>


谢谢..

最简单的方法是在
列表视图中定义布局。这是我用过的。我用一个应用程序做了类似的事情,希望它能有所帮助:

此时将显示列表视图:

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/view" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@drawable/logo"
        android:orientation="vertical" >
    </LinearLayout>

    <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="a15009789e230a7" />
    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/linearLayout1"
        android:layout_above="@+id/adView"
        android:layout_centerHorizontal="true"
        android:background="@drawable/background"
        android:cacheColorHint="#00000000" >
    </ListView>






</RelativeLayout>
这是适配器:

    @Override
protected void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.dining);



    // Create ListData object to hold list data
    ListData newListItem = new ListData();

    try
    {
        // parse data and populate the list view
        this.itemObject = newListItem.getData(DATAURL);
        Log.e(TAG, "item object: " + this.itemObject.toString());
        ListAdapter adapter = new ListAdapter(this, R.layout.dininglistview, this.itemObject);
        // Create listview
        this.listView1 = (ListView) this.findViewById(android.R.id.list);
        this.listView1.setAdapter(adapter);
        GetImagesTask imgTask = new GetImagesTask();
        imgTask.execute(this.itemObject);

        AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest re = new AdRequest();
        adView.loadAd(re);

    }
    catch (InterruptedException e)
    {

        Log.e(TAG, "Unexpected error", e);
    }
    catch (ServiceException e)
    {
        AlertDialog alertDialog = new AlertDialog.Builder(DiningActivity.this).create();
        alertDialog.setTitle("Temporarily unavailable");
        alertDialog.setMessage("Please contact top25@uievolution.com");
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            // if there is an error, send the user to the home page
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                Intent homeIntent = new Intent(DiningActivity.this, HomeActivity.class);
                DiningActivity.this.startActivity(homeIntent);

            }
        });
        alertDialog.show();
    }
    // implement dining adapter

}
我希望这有帮助!祝你好运

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:padding="10dp" >

    <ImageView
        android:id="@+id/imgThumb"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="5dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/diningbutton"
        android:gravity="center_vertical" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/imgThumb"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/diningTitle"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="true"
            android:layout_alignParentTop="true"
            android:gravity="top"
            android:paddingTop="5dp"
            android:textColor="#000000"
            android:textSize="16dp"
            android:textStyle="normal" />

        <TextView
            android:id="@+id/listSubHeader"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="bottom"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"
            android:textColor="#000000"
            android:textSize="14dp"
            android:textStyle="italic" />
    </LinearLayout>

</RelativeLayout>
    @Override
protected void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.dining);



    // Create ListData object to hold list data
    ListData newListItem = new ListData();

    try
    {
        // parse data and populate the list view
        this.itemObject = newListItem.getData(DATAURL);
        Log.e(TAG, "item object: " + this.itemObject.toString());
        ListAdapter adapter = new ListAdapter(this, R.layout.dininglistview, this.itemObject);
        // Create listview
        this.listView1 = (ListView) this.findViewById(android.R.id.list);
        this.listView1.setAdapter(adapter);
        GetImagesTask imgTask = new GetImagesTask();
        imgTask.execute(this.itemObject);

        AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest re = new AdRequest();
        adView.loadAd(re);

    }
    catch (InterruptedException e)
    {

        Log.e(TAG, "Unexpected error", e);
    }
    catch (ServiceException e)
    {
        AlertDialog alertDialog = new AlertDialog.Builder(DiningActivity.this).create();
        alertDialog.setTitle("Temporarily unavailable");
        alertDialog.setMessage("Please contact top25@uievolution.com");
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            // if there is an error, send the user to the home page
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                Intent homeIntent = new Intent(DiningActivity.this, HomeActivity.class);
                DiningActivity.this.startActivity(homeIntent);

            }
        });
        alertDialog.show();
    }
    // implement dining adapter

}