Java 从菜单活动调用GPS活动
我的基本应用程序有一个小问题。当我试图从列表(“IIMODULE”)开始第二个位置时,我在手机上没有任何反应。这是LogCat的日志:Java 从菜单活动调用GPS活动,java,android,android-layout,Java,Android,Android Layout,我的基本应用程序有一个小问题。当我试图从列表(“IIMODULE”)开始第二个位置时,我在手机上没有任何反应。这是LogCat的日志: System.err(3416): java.lang.ClassNotFoundException: com.example.aplikacjatestowa.IIMODULE 我对这个错误几乎没有研究,但我没有发现任何具体的案例。谁能看出我的错误?有什么想法吗 菜单类: public class Menu extends ListActivity { S
System.err(3416): java.lang.ClassNotFoundException: com.example.aplikacjatestowa.IIMODULE
我对这个错误几乎没有研究,但我没有发现任何具体的案例。谁能看出我的错误?有什么想法吗
菜单类:
public class Menu extends ListActivity {
String[] mainMenuStrings = { "MAINACTIVITY", "IIMODULE", "III_Module",
"empty" };
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this,
android.R.layout.simple_list_item_1, mainMenuStrings));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String localSelector = mainMenuStrings[position];
Class ourClass;
try {
ourClass = Class.forName("com.example.aplikacjatestowa."
+ localSelector);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
以下是AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aplikacjatestowa"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="com.example.aplikacjatestowa.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="com.example.aplikacjatestowa.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".GpsModule"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="com.example.aplikacjatestowa.IIMODULE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
问题是没有加载IIMODULE类,是否包含jar
请同时抄送包裹。您正在尝试获取一个不存在的类
ourClass = Class.forName("com.example.aplikacjatestowa."+ localSelector);
Intent ourIntent = new Intent(Menu.this, ourClass);
而不是使用上面的代码
Intent ourIntent = new Intent("com.example.aplikacjatestowa."+ localSelector)
但是你仍然没有III_模块的操作标签,清单中的任何应用程序都是空的你的应用程序中有名为
IIMODULE
的类吗?天哪。。。我对这样的小错误没有任何解释。对不起,谢谢
Intent ourIntent = new Intent("com.example.aplikacjatestowa."+ localSelector)