我正在尝试制作一个 webview 应用程序,但我对此并不擅长。
我只是想这样做:我有一个网站,我想在默认浏览器中打开外部链接,例如目标 _blank。
我的活动:
public class MainActivity extends AppCompatActivity {
DrawerLayout drawerLayout;
ActionBarDrawerToggle drawerToggle;
NavigationView navigation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
OneSignal.startInit(this).init();
initInstances();
WebView myWebView = (WebView) findViewById(R.id.webView1);
myWebView.loadUrl("http://mywebsite.domain.com/myprofile/");
myWebView.setWebViewClient(new WebViewClient());
}
private void initInstances() {
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
drawerToggle = new ActionBarDrawerToggle(MainActivity.this, drawerLayout, R.string.hello_world, R.string.hello_world);
drawerLayout.setDrawerListener(drawerToggle);
navigation = (NavigationView) findViewById(R.id.navigation_view);
navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
String menu1 = "https://mywebsite.domain.com/myprofile/";
String menu2 = "https://mywebsite.domain.com/exit";
String menu3 = "https://mywebsite.domain.com/discover/";
String menu4 = "https://mywebsite.domain.com/settings/";
String menu5 …Run Code Online (Sandbox Code Playgroud)