I'm using a listview with my own implementation of baseadapter. Before adding the main list items to the listview and setting the Adapter i add a footer, with addFooterView(), to the listview. The footer is a normal listview item with a custom view and two buttons.
And here comes my problem:
How can i add a onClick() event to this buttons? i tried it in the getView() method of my baseadapter but that does not work. :/
I need these two buttons at the bottom of my listview as back and forward buttons, cause i don't want too much items at once in the listview.
thx
Since the footer is just a normal View
, you should be able to inflate the view, get a handle to the Button
with findViewById()
and add an onClick()
handler.
Assuming that your footer is an XML layout:
View footer = View.inflate(this, R.layout.footer, null);
getListView().addFooterView(foot, null, false);
Button forward = footer.findViewById(R.id.forward);
forward.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
}
});
Hopefully, that's enough to get you started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With