Reputation: 3139
I have ScrollView
header of the listView with a lot of elements. And footer with 2 buttons. And when I fill the headers elements, and push footer's button, it is not firing. And when I click on the header's item
btnSubmitOrder.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
header.clearFocus();
btnSubmitOrder.setFocusable(true);
Log.i("new order button","fires");
}
});
the text of the Log item shows in the LogCat the same times as I pushed it. So why does this happen? How can I make footer's button react immediately?
Upvotes: 1
Views: 1324
Reputation: 62519
it could be that the listview and footerview are fighting for focus try this:
mylistView.addFooterView(footerView, null, false);
where false tells the footer its not selectable. I tested this myself and the buttons inside the footer respond to touches now. I hope this an acceptable answer.
otherwise you'll have to use a ontouchlistener as you mentioned as the listview and button are fighting for focus and listview is winning.
Upvotes: 0
Reputation: 3139
I resolved issue by using
btnSubmitOrder.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN)
{
header.clearFocus();
}
}
});
Upvotes: 2
Reputation: 144
add android:onClick="onYourClick" and android:clickable="true" to your footer xml
in your ListActivity add function:
public void onYourClick(View v){
header.clearFocus();
btnSubmitOrder.setFocusable(true);
Log.i("new order button","fires");
}
Upvotes: 1