How customize AndroidHive Slide Menu

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 09:23:17

问题


for make a slidemenu i use AndroidHive.com slidemenu sample.

at first i make slidemenu in this form :

now i need to change to this form :

for change first row of listview i use this codes :

    View header = getLayoutInflater().inflate(R.layout.slidemenu_header, null);
    mDrawerList.addHeaderView(header); 

but for end of list items(item 10 & a,b,c,d items) , Whether there is a way that i can put them to SlideMenu listview?

or what i should to do?

it possible to inflate view to Desired position in Listview?


回答1:


To having multiple view inside of your Sliding menu ListView you can override two functions inside of your menu adapter :

@Override
public int getViewTypeCount() {
    return 3;
}

@Override
public int getItemViewType(int position) {
      if (position == 0) {
        return 0;
      } else if(position == 1) {
        return 1;
      }
      else
      return 2;
}

then inside of your getView inflate the row according to the result from getItemViewType(position)

View rowView = convertView;
    int Layout;

    if(getItemViewType(position) == 0)//change layout according to being header or detail in ListView
    {
        Layout = R.layout.first_view;
    }
    else if(getItemViewType(position) == 1)
    {
        Layout = R.layout.second_view;
    }
    else
    {
        Layout = R.layout.third_view;
    }


来源:https://stackoverflow.com/questions/25957767/how-customize-androidhive-slide-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!