开发者

Button in slidingdrawer!

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) {

        }
    });

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜