如何解决单击按钮时抽屉不会关闭
我希望我的导航抽屉在按下其中的按钮时关闭,但它没有关闭。我试过 drawerLayout.closeDrawer(GravityCompat.START) 和 drawerLayout.closeDrawers();但这些在这方面似乎不起作用。
我的 MainActivity.java
library(shiny)
library(ggplot2)
library(dplyr)
shinyServer(function(input,output) {
output$ufoPlot <- renderPlot({
ufo_data_filter <- filter(ufo_data,Country == input$Country)
ggplot(data = ufo_data_filter) +
geom_bar(mapping = aes(x = Shape))+
labs(
title = "Number of Different Shaped UFO Observations",x = "Shape of UFO Sighted",y = "Number of Observations in 2016"
)
})
})
这是我的 activity_main.xml 我的组件顺序不正确吗?在这方面重要吗?
@SuppressLint("NonConstantResourceId")
@Override
public boolean onNavigationItemSelected(@NonNull @NotNull MenuItem item) {
switch (item.getItemId()) {
case R.id.nav_share:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBodyText = "Check out this awesome store at https://google.com";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Check out our store");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,shareBodyText);
startActivity(Intent.createChooser(sharingIntent,"Sharing Option"));
return true;
}
drawerLayout.closeDrawer(GravityCompat.START);
return true;
}
private void setNavigationViewListener() {
NavigationView navigationView = findViewById(R.id.nv);
navigationView.setNavigationItemSelectedListener(this);
}
@SuppressLint({"SetJavaScriptEnabled","NonConstantResourceId"})
@Override
public boolean onoptionsItemSelected(MenuItem item) {
if (actionBarDrawerToggle.onoptionsItemSelected(item)) {
return true;
}
return super.onoptionsItemSelected(item);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。