【发布时间】:2014-01-06 17:14:51
【问题描述】:
我开发了一个简单的 android 应用程序,用于显示像 Google 这样的网络。它工作正常,从 Eclipse 启动时,从已安装的模拟器应用程序重新启动时不起作用。
这是我的WebView活动代码
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView mWebView = (WebView) findViewById(R.id.webView);
mWebView.loadUrl("http://www.google.com");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
这是我的 .xml 文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
【问题讨论】:
-
怎么不工作?
-
你的意思是当你点击模拟器上的应用程序图标时,应用程序没有启动?还是会崩溃?
-
将设备连接到桌面并在 log cat 中,检查日志并将其发布在此处。
-
@EmbattledSwag 当我点击模拟器上的应用程序图标时,它只显示没有 webview 的活动,它不会崩溃。
-
@prem 对不起!但我听不懂,你说什么。