I'm having a button in a sliding drawer in a Android Application. The problem is it does not seem to react to any clicks as normal buttons do.
I'm guessing the problem is that it's a different view than buttons on the normal view. If I implement a button the normal way like this
myAgenda = (Button)findViewById(R.id.BtnMyAgenda); myAgenda.setOnClickListener(this);
public void onClick(View v) { switch(v.getId()){ case R.id.BtnMyAgenda: test.setAnimation(leftLeft); test.startAnimation(leftLeft); break;
}
I'm guessing there is something wrong with the above code since the button is in a SlidingDrawer and not in the "normal" view. Any ideas how to fix the problem?
Here is the code
Register with event listner like below code button.setOnClickListener(clickButtonListener);
and create this listner for button
private OnClickListener clickButtonListener= new OnClickListener()
{
@Override
public void onClick(View v)
{
if(v == button)
{
}
}
}
I actually found the solution to the problem, I simply created a new view.onclicklistener specific to that button.
final Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { } });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.