문제

I have the following code in resultlookup.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:id="@+id/layoutResultOuter"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:padding="5dp">
    <TextView
            android:id="@+id/txtResultLeadCode"
            style="@android:style/TextAppearance.Large"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="ID" />
    <LinearLayout android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
        <TextView
                android:id="@+id/txtResultFirstName"
                style="@android:style/TextAppearance.Small"
                android:singleLine="true"  android:text="First Name" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        <TextView
                android:id="@+id/txtResultspace"
                style="@android:style/TextAppearance.Small"
                android:singleLine="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=" " />
        <TextView
                android:id="@+id/txtResultLastName"
                style="@android:style/TextAppearance.Small"
                android:singleLine="true" android:text="Last Name" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>

Now, I want this layout to be used in a grid view, as 1 of it's row. The grid is a single column grid.

The data is stored in SQLite DB, I retrieve the data and have to display it in the grid format.

Read some where that I can use "View Inflater" or "Layout Inflater". If there is any sample code, please let me know.

I want some thing like this:

resultant image

도움이 되었습니까?

해결책

I think you can simply use the <include> tag. Here's how you do it.

다른 팁

By using custom adapter you can use your own layout for populating items in the GridView.

use above layout as the item and inflate it in getView() method it will work properly..

check this once : custom adapter for grid view

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top