0
我使用monodevelop ti android開發。我想添加一個加載項目在我的列表的末尾,從互聯網加載。 我用這個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。 我不明白爲什麼它是? 可以幫助我嗎?
但你所提供的高度爲125dip? –
我想它是寬度爲fill_parent – user1682893