一个slidingmenu和button点击获取问题

我slidingmenu布局的xml里加了个button,想弄点点击效果,我的确是获取到了这个控件,但是点击却没有反应,请问这是为啥。。。。

package slidingmenu;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.example.slidingmenu.R;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenedListener;

public class MainActivity extends Activity {
private Button btn;
SlidingMenu slidingMenu;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    slidingMenu = new SlidingMenu(this);
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    slidingMenu.setMenu(R.layout.slidingmenu);
    slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    View view = View.inflate(MainActivity.this, R.layout.slidingmenu, null);
    btn = (Button) view.findViewById(R.id.btn_rere);
    btn.setOnClickListener(onClickListener);
}

OnClickListener onClickListener = new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Toast.makeText(MainActivity.this, "rerer", Toast.LENGTH_SHORT)
                .show();
        setTitle("rerer");
        Intent intent = new Intent(MainActivity.this, Rere.class);
        startActivity(intent);
    }
};

@Override
public boolean onKeyDown(int key, KeyEvent event) {
    switch (key) {
    case KeyEvent.KEYCODE_MENU:
        slidingMenu.toggle(true);
        break;

    default:
        break;
    }
    return false;
}

}

查看全部
biaodiluer
表滴卤儿
2015/08/29 09:16
  • java
  • android
  • slidingmenu
  • 点赞
  • 收藏
  • 回答
    私信

1个回复