Android 使用if/else子句时以一种意图调用多个字符串
有没有一种方法可以只使用一个目的调用多个字符串,比如在webview活动中,使用if/else子句,如下所示:Android 使用if/else子句时以一种意图调用多个字符串,android,string,android-intent,webview,Android,String,Android Intent,Webview,有没有一种方法可以只使用一个目的调用多个字符串,比如在webview活动中,使用if/else子句,如下所示: public void openGo(View v) { TextView display = (TextView) findViewById(R.id.display); String check = display.getText().toString(); if (check.contentEquals("1")) { Intent i =
public void openGo(View v) {
TextView display = (TextView) findViewById(R.id.display);
String check = display.getText().toString();
if (check.contentEquals("1")) {
Intent i = new Intent(this, WebViewActivity.class);
i.putExtra("keyHTML", "file:///android_asset/page1.html");
startActivity(i);
} else if (check.contentEquals("10")) {
Intent i = new Intent(this, WebViewActivity.class);
i.putExtra("keyHTML", "file:///android_asset/page2.html");
startActivity(i);
如果字符串1、12和16具有相同的webview页面,如何将它们链接在一起?这可能像下面这样吗?请注意粗体文本
public void openGo(View v) {
TextView display = (TextView) findViewById(R.id.display);
String check = display.getText().toString();
**if (check.contentEquals("1,12,16")) {**
Intent i = new Intent(this, WebViewActivity.class);
i.putExtra("keyHTML", "file:///android_asset/page1.html");
startActivity(i);
} else if (check.contentEquals("10")) {
Intent i = new Intent(this, WebViewActivity.class);
i.putExtra("keyHTML", "file:///android_asset/errorpage.html");
startActivity(i);
谢谢。使用
if(check.contentEquals(“1”)| check.contentEquals(“12”)| check.contentEquals(“16”)
我觉得你用的东西不正确谢谢,我没有用我贴的东西,只是为了让你明白我想要什么,我会试试这个,非常感谢@佐勒