问题
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