Android: Why WebView doesn't finish properly?
I'm developing an Android application where the user can select from a 开发者_如何学编程menu a point, which leads to a specific listview. If the user now clicks on a item he gets to a webview of it, where he can go to other pages and so on. Now i want that the Webview closes, when the user clicks on the "Back-Button" on his mobilephone. In all other activitys I got it. But once the webview is called I got stuck in a loop between the main menu and the last visited webview. Can you maybe help me? I really don't know why the webview doesn't finish properly.
This is the code from the webview-class
public class News extends Activity {
WebView mWebView;
String newsurl;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {       
      super.onCreate(savedInstanceState);
      Bundle extras = getIntent().getExtras();
      if(extras != null){
          newsurl = extras.getString("newsurl");
      }
      String bla = connect(newsurl);
      TextView tv = new TextView(this);
      tv.setText(bla);
      setContentView(R.layout.webview);
        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        class HelloWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        }
        mWebView.setWebViewClient(new HelloWebViewClient());
        mWebView.loadDataWithBaseURL("http://www.onpsx.net", bla, "text/html", "iso-8859-1", null);
      };
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) {
          if ((keyCode == KeyEvent.KEYCODE_BACK)) {               
              finish();
              return true;
          }
          return super.onKeyDown(keyCode, event);
      }
The connect Method isn't shown, because I think it is unnecessary. It only parses the content from the Page properly. I hope you can help me. Thanks!
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论