How To Make List Header And Footer Not Click Able?
I have a list with footer and header. I added onLongClick to delete item from list. When I press long on header it remove first item from list. When I click on last item or footer
Solution 1:
You have to use addHeaderView (View v, Object data, boolean isSelectable) and addFooterView (View v, Object data, boolean isSelectable) to make Header and Footer of ListView not clickable.
Just pass false
in place of isSelectable
for Header and Footer.
Pseudo code,
listview.addHeaderView(header_view, null, false);
listview.addFooterView(footer_view, null, false);
Solution 2:
For Seperate Context menu in HeaderView
and FooterView
of ListView
.
@OverridepublicvoidonCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflaterinflater= getMenuInflater();
if (((AdapterContextMenuInfo)menuInfo).position == 1) {
inflater.inflate(R.menu.foo1, menu); // HEADER MENUreturn;
}
elseif(((AdapterContextMenuInfo)menuInfo).position == listView.getAdapter().getCount() + 1) {
inflater.inflate(R.menu.foo2, menu); // FOOTER MENUreturn;
}
inflater.inflate(R.menu.foo3, menu);
}
Solution 3:
If you add list header on your ListView, the index of your first item in the adapter is 1. If you didn't add header, the index of your first item in the adapter is 0.
Post a Comment for "How To Make List Header And Footer Not Click Able?"