需求:
1、打开应用,界面上显示一个按钮
2、点击按钮,打开一个webview,webview里显示我需要的页面
3、按回退按钮,可退回之前显示按钮的页面我的代码:
activity_main.xml中加入了
<Button
        android:id="@+id/show_pay_card_page"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="测试"
        android:layout_marginTop="200dp" />
在MainActivity.java中的onCreate()方法中加入
Button btn = (Button)findViewById(R.id.show_pay_card_page);
        btn.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
wv = new WebView(MainActivity.this);
wv.loadUrl("http://www.baidu.com");
setContentView(wv);
    
    
Toast.makeText(MainActivity.this, "abc", Toast.LENGTH_SHORT).show();
}
        });
现在的问题是,我跳转到webview,再按回退按钮,会直接关闭应用,而不能够退回之前的界面
android新手,搜了很多地方没有找到答案,求各位大神解决