从网址获取变量?

当前网址:example.com/?lang = hin 我要做的事情:菜单项标题,显示是否放置标题名称(tit1.setTitle(“ Home”);)

我想要:如果lang = hin设置菜单标题。我想用lang hin或英文设置印地文名称

错误:找不到符号变量tit11

这是我的代码,请建议我。

MainActivity.java

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

        setContentView(R.layout.activity_main);
        webView = (WebView)findViewById(R.id.webView);
        webView.setWebViewClient(new HelpClient());
        webView.getSettings().setJavaScriptEnabled(true); //enable javascript
        webView.loadUrl(webAdress);

        String url = webView.getUrl();
        Uri uri = Uri.parse(url);
        String server = uri.getAuthority();
        String path = uri.getPath();
        String protocol = uri.getScheme();
        String lang = uri.getQueryParameter("lang");
        if(lang.equals("hin")){
            String tit11 = "होम";
            String tit22 = "अबाउट";
            String tit33 = "सेटिंग";
}else{
            String tit11 = "Home";
            String tit22 = "About";
            String tit33 = "Setting";
}

        BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
        Menu menu = bottomNavigationView.getMenu();  

            MenuItem tit1 = menu.findItem(R.id.home);  
            tit1.setTitle(tit11);
            MenuItem tit2 = menu.findItem(R.id.about);  
            tit2.setTitle(tit22);
            MenuItem tit3 = menu.findItem(R.id.setting); 
            tit3.setTitle(tit33);

}
评论