weixin_31119207
weixin_31119207
采纳率70%
2015-11-27 09:55 阅读 4.6k
已采纳

DrawerLayout 添加完监听事件 不进onDrawerClosed()和 onDrawerOpened()

import android.support.v4.widget.DrawerLayout;
import android.support.v4.app.ActionBarDrawerToggle;

public class MainActivity extends Activity{

private DrawerLayout drawer;

private ActionBarDrawerToggle toggle;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.menu);

    drawer = (DrawerLayout) findViewById(R.id.dra);

    toggle = new ActionBarDrawerToggle(this, drawer, R.drawable.searchmap, R.string.drawer_open,R.string.drawer_close){

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            Log.i("mag", "关闭");

        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            Log.i("mag", "打开");

        }

    };

    drawer.setDrawerListener(toggle);
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐