2012-12-10 3 views
0

monodevelop ti android development를 사용합니다. 인터넷에서로드하는 목록의 끝에로드하는 항목을 추가하고 싶습니다. 나는 제안이이 XML 파일을 사용레이아웃이 런타임에 제대로 표시되지 않습니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="125dp"> 
<RelativeLayout 
    android:id="@+id/LoadingRealtive" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dip" 
    android:background="@drawable/List_Menu_Bg" 
    > 
    <ProgressBar 
     android:id="@+id/loadingListItems" 
     style="@style/GenericProgressIndicator" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" /> 
    <TextView 
     android:text="Loading..." 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/loadingListItems" 
     android:id="@+id/textView1" 
     android:layout_centerHorizontal="true" 
     android:textColor="#6b6b6b" /> 
</RelativeLayout> 
<RelativeLayout 
    android:id="@+id/MainRelative" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dip" 
    android:background="@drawable/List_Menu_Bg">...MyListItems </RelativeLayout></LinearLayout> 

을 내 목록보기에이 코드를 사용 :

public override View GetView (int position, View convertView, ViewGroup parent) 
    { 
     View vi = convertView; 

     try { 

      if (convertView == null) 
       vi = activity.LayoutInflater.Inflate (Resource.Layout.list_row, parent, false); 

      RelativeLayout LoadingRelative=(RelativeLayout) vi.FindViewById (Resource .Id.LoadingRealtive); 
      RelativeLayout ContentRelative=(RelativeLayout) vi.FindViewById (Resource .Id.MainRelative); 



      if(Data [position ] == null) 
      { 
       ContentRelative .Visibility =ViewStates.Gone ; 
       LoadingRelative .Visibility = ViewStates.Visible ; 
      }else{ 
       ContentRelative .Visibility =ViewStates.Visible ; 
       LoadingRelative .Visibility = ViewStates.Gone ;<...MyListCodes...> 
      } 
     } catch (Exception ex) { 
      Common.HandleException (ex); 
     } 
     return vi; 
    } 

그것은 로딩 레이아웃로드가 수행해야합니다 동안 wrap_content이다 멋지군이 문제를 일을 fill_parent를로드하십시오. 이유가 무엇인지 이해가 안됩니까? 어떤 몸이라도 나를 도와 줄 수 있습니까?

+0

하지만 당신은 높이 125dip가 될 수를 제공 한 ?? –

+0

폭이 – user1682893

답변

0

linearlayout을 래퍼 뷰로 사용하는 경우 fill_parent 특성을 가진 채움보기에 android : weight를 제공해야합니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="125dp"> 
<RelativeLayout 
    android:id="@+id/LoadingRealtive" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dip" 
    android:background="@drawable/List_Menu_Bg" 
    android:weight="1" 
    > 
    <ProgressBar 
     android:id="@+id/loadingListItems" 
     style="@style/GenericProgressIndicator" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" /> 
    <TextView 
     android:text="Loading..." 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/loadingListItems" 
     android:id="@+id/textView1" 
     android:layout_centerHorizontal="true" 
     android:textColor="#6b6b6b" /> 
</RelativeLayout> 
<RelativeLayout 
    android:id="@+id/MainRelative" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dip" 
    android:background="@drawable/List_Menu_Bg"   
    android:weight="1" > 
</RelativeLayout> 

+0

인 fill_parent하고 싶습니다. 앱에 오류가 발생했습니다. 하지만 linearLaout을 relativelayout으로 변경했는데 제대로 작동합니다. – user1682893

관련 문제