終於在適配器添加多一個屬性ObjectDrawerItem
public class ObjectDrawerItem {
public int icon;
public String name;
public boolean footer;
// Constructor.
public ObjectDrawerItem(int icon, String name,boolean footer) {
this.icon = icon;
this.name = name;
this.footer=footer;
}
}
則頁腳行
drawerItem[2] = new ObjectDrawerItem(R.drawable.ic_action_share, "Help",true);
變化listview_item_row.xml
到
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:padding="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="[email protected]/rlRow">
<ImageView
android:id="@+id/imageViewIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingRight="10dp" />
<TextView
android:id="@+id/textViewName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/imageViewIcon"
android:paddingRight="10dp"
android:text="Folder name here."
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#ffffff" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="[email protected]/rlFooter">
</RelativeLayout>
</RelativeLayout>
getview
if(folder.Footer)
{
(RelativeLayout) listItem.findViewById(R.id.rlFooter).setVisibility(View.Visible);
(RelativeLayout) listItem.findViewById(R.id.rlRow).setVisibility(View.Gone);
}
else
{
(RelativeLayout) listItem.findViewById(R.id.rlFooter).setVisibility(View.Gone);
(RelativeLayout) listItem.findViewById(R.id.rlRow).setVisibility(View.Visible);
}
謝謝:)這將工作,我猜 – Broadwell