抱歉,我是安卓应用的新手。创建。我已经提到了几乎所有的解决方案,但这只是行不通……而且我在下面的简单代码中看不到任何问题。我的应用程序很简单,加载启动画面,然后加载 webview。下面是什么问题?
我得到的错误是:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.wwes.EZEE/com.wwes.EZEE.SecondPage}; have you declared this activity in your Manifext.xml
[评论]请。看下面,我已经声明过了。怎么了?
文件是:
MainActivity.java:在这里我加载启动画面图像。
package com.example.EZEE; import com.wwes.EZEE.SecondPage; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Thread for displaying the Splash Screen // Thread splash_screen = new Thread() { public void run() { try { sleep(1000); } catch (Exception e){ e.printStackTrace(); } finally { Intent i = new Intent(MainActivity.this, SecondPage.class); startActivity(i); } } }; splash_screen.start(); } @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; }
SecondPage.java:这会加载 webview。
package com.wwes.EZEE; public class SecondPage extends Activity { WebView browserView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Removed the title bare in the Application // requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_second_page); // Creation of the Webview found in the XML Layout file // browserView = (WebView)findViewById(R.id.webView1); // Enable Javascripts // browserView.getSettings().setJavaScriptEnabled(true); browserView.getSettings().... browserView.getSettings().... browserView.getSettings().... browserView.getSettings().setLoadsImagesAutomatically(true); // Removed both vertical and horizontal scroll bars // browserView.setVerticalScrollBarEnabled(false); browserView.setHorizontalScrollBarEnabled(false); browserView.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Webview Wrap // browserView.loadUrl("http://www.ABCDE.com"); browserView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false; } }); } @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; } @Override public void onBackPressed() { if(browserView.canGoBack()) browserView.goBack(); else super.onBackPressed(); }
}
活动主.xml:
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:background="#800808" android:scaleType="fitStart" android:visibility="visible" android:src="@drawable/logo" />
4)activity_second_page.xml:
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:visibility="gone"
android:layout_alignParentTop="true" />
5)清单.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wwes.EZEE"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
----------------------------------updated----------------------------------
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.wwes.EZEERACKS.MainActivity" //// UPDATED ///
android:configChanges="keyboard|keyboardHidden|orientation|smallestScreenSize"
android:screenOrientation="portrait"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.wwes.EZEE.SecondPage"
android:label="@string/title_activity_second_page" >
</activity>
</application>
</manifest>
谢谢您的帮助!