[英]How to click in the Toolbar on the navigation button?
not working for me 不为我工作
activity.findViewById(R.string.abc_action_bar_up_description).performClick();
I set in activity 我开始活动
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
...
}
});
To make a click on the navigation button which is located in the toolbar you need to do the following: 要单击工具栏中的导航按钮,您需要执行以下操作:
Add text to the navigation button 向导航按钮添加文本
toolbar.setNavigationContentDescription("up");
After finding it in the following way 按照以下方式找到它之后
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.