在我的第一个视图中,我有 4 个图标,如 facebook、twitter 等。当我按下其中一个图标时,它会将我带到相关网站。但是当我按下后退按钮时,它首先向我显示一个空白活动,然后我必须再次按下后退按钮才能到达我的第一个活动。
有什么帮助吗?提前致谢
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.button1:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 1);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
case R.id.button2:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 2);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
case R.id.button3:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 3);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
case R.id.button4:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 4);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
}
}
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webview=(WebView)findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
Intent get_icon=getIntent();
Bundle get_bundle=get_icon.getExtras();
int icon_id=get_bundle.getInt("icon_position");
if(icon_id==1){
webview.loadUrl("http://www.facebook.com");
}
if(icon_id==2){
webview.loadUrl("http://www.twitter.com");
}
if(icon_id==3){
webview.loadUrl("http://www.plus.google.com");
}
if(icon_id==4){
webview.loadUrl("http://www.blogger.com");
}
}