Android添加页脚到导航抽屉
问题描述:
我目前在我的一个应用中使用了一个导航抽屉,并且想要添加一个页脚空间,比如google,在那里我可以放置设置和帮助& FAQ快捷方式(只需打开任意谷歌应用即可找到他们)。我目前在这里使用代码foubd:https://www.codeofaninja.com/2014/02/android-navigation-drawer-example.html如何在此处显示的抽屉中添加页脚空间?Android添加页脚到导航抽屉
答
终于在适配器添加多一个属性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