![](/img/trans.png)
[英]Android how toggle with the button in toolbar to open/close navigation drawer with Fragments
[英]How to click in the Toolbar on the navigation button?
不为我工作
activity.findViewById(R.string.abc_action_bar_up_description).performClick();
我开始活动
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
...
}
});
要单击工具栏中的导航按钮,您需要执行以下操作:
向导航按钮添加文本
toolbar.setNavigationContentDescription("up");
按照以下方式找到它之后
final ArrayList<View> outViews = Lists.newArrayList();
activity.findViewById(R.id.toolbar).findViewsWithText(outViews, "up", View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
outViews.get(0).performClick();
您应该将您的东西称为R.id.yourStuff
&&检查是否为android:clickable="true"
(如果不是按钮)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.