2012-02-17 2 views
1

복잡한 레이아웃을 사용하는 I가어떻게 그리드 행

<?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> 

지금, 나는이 레이아웃이의 행의 1로, 그리드 뷰를 사용하고 싶지 resultlookup.xml에 다음 코드. 그리드는 단일 열 그리드입니다.

데이터가 SQLite DB에 저장되고 데이터를 검색하여 표 형식으로 표시해야합니다.

"View Inflater"또는 "Layout Inflater"를 사용할 수있는 곳을 읽어보십시오. 샘플 코드가 있으면 알려주십시오.

나는 어떤 것을 다음과 같이합니다 :

resultant image

+0

문제 해결 ... "어댑터"클래스 에서 다음 코드를 사용합니다. LinearLayout myLayout = (LinearLayout) findViewById (R.id.layoutResultOuter); LayoutInflater inflater = (LayoutInflater) context.getSystemService \t (Context.LAYOUT_INFLATER_SERVICE); View hiddenInfo = inflater.inflate (R.layout.resultleadlookup, myLayout, false); addView (hiddenInfo); ' – Pallavi

+0

XML 파일에 도 사용됩니다. 덕분에 @ 고스트 – Pallavi

답변

1

난 당신이 단순히 <include> 태그를 사용할 수 있다고 생각합니다. Here's 어떻게하는지.

+0

나는 그리드를 동적으로 채우고있다. XML에있는이 말이 맞습니다. – Pallavi

+0

예. 그렇지만 동적 필링에 대해서는 언급하지 않았습니다. – Ghost

+0

'LinearLayout myLayout = (LinearLayout) findViewById (R.id.layoutResultOuter); LayoutInflater inflater = (LayoutInflater) context.getSystemService \t (Context.LAYOUT_INFLATER_SERVICE); View hiddenInfo = inflater.inflate (R.layout.resultleadlookup, myLayout, false); addView (hiddenInfo); '그리드 어댑터 – Pallavi

0

사용자 정의 어댑터를 사용하여 당신은의 GridView에서 항목을 채우기 위해 자신의 레이아웃을 사용할 수 있습니다.

는 항목으로 레이아웃 위

사용() 메소드가 제대로 ..

확인이 한 번 작동의 getView에서 팽창 : custom adapter for grid view