Reputation: 41
os: Android 2.2
I got a problem. When I input the Quantity in the EditText, if I click the save button in the up-right, it has to be clicked twice to trigger the OnClick Event. However, while I click the up-left back button, one click is enough.
I debugged and find the button has to get the focus the first time. However, why the back button doesn't need that?
And how to make the save button just need to click once?
Below is the click listener event.
First one is the button click listener. Second one is the button click listener.
Button.OnClickListener ui_titlebar_back_btn_Lsn = new Button.OnClickListener(){
public void onClick(View v)
{
if (itemLayout.isShown()){
showHeaderLayout();
}
else if(HeaderLayout.isShown()){
finish();
}
}
};
Button.OnClickListener ui_titlebar_help_btn_Lsn = new Button.OnClickListener(){
public void onClick(View v)
{
if (itemLayout.isShown()){
tempSaveItem();
}else if(HeaderLayout.isShown()){
submitOrder();
}
}
};
Upvotes: 4
Views: 1511
Reputation: 29
you may also add Method to Button for onClick in xml and use the same method in activity.As,
private void blabla(view v){
if(v= ui_titlebar_back_btn){
//do something
}
else if(v==blabla){
//do something
}
}
Upvotes: 0
Reputation: 143
i guess you may use custom onclick method,like this :
private OnClickListener event = new OnClickListener() {
public void onClick(View v) {
//do something
}
}
may this help you.thanks
Upvotes: 1