7

私は2つのクラスを持っています。 1つは基本的な指示画面であり、その画面には他のクラスに行くことができるメニューがあります。他のクラスはMapActivityです。問題は他のクラスが見つからないということです。私はクラスを見つける意図を宣言するいくつかの異なる方法を試しました。これは私が試した最新のものである:(?それが問題を引き起こす可能性があります)活動とマップクラスはMapActivityを拡張する基本的なクラスである拡張メニュー項目選択のAndroid開始アクティビティ

@Override 
public boolean onCreateOptionsMenu(Menu menu){   
    MenuInflater inflater = getMenuInflater(); 
    inflater.inflate(R.menu.mainmenu, menu); 
    return true; 
} 
@Override 
public boolean onOptionsItemSelected(MenuItem item){ 
    switch(item.getItemId()){ 
    case R.id.goToMap: 
     Intent intent = new Intent(); 
     intent.setClassName(Main.this, "Map.Class"); 
     startActivity(intent); 
     return true;    
    } 
    return false; 
} 

その基本的なクラス。そして、ここに私のマニフェストファイルの重要な部分である:

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <activity android:name=".Campus_Map" 
       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=".Main" android:label="Instructions" ></activity> 
    <activity android:name=".Map" android:label="Map"> 
     <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     </intent-filter> 
    </activity> 

</application> 

編集:何が起こっているかを把握するLogCatを見ると が、私はjava.lang.NoClassDefFoundErrorのと言って他のいくつかのメッセージ」を取得しています"クラス/ .Main.runから参照されるクラス./Mapを見つけることができませんでした"と "VFY:constクラス37を解決できません"

答えて

15

あなたはこれをやったことは間違っていた!それは<application> </application>タグ内でなければなりません。そうでないとエラーが発生します

3

この方法で試しましたか?

Intent launchNewIntent = new Intent(CurrentClass.this,SecondClass.class); 
startActivityForResult(launchNewIntent, 0); 
1

あなたがいる場合、あなたのマニフェスト

<uses-library android:name="com.google.android.maps" /> 

にこのラインを実装する必要があります。あなたは次のように使用できるとのAndroidManifest.xmlに両方の活動を追加することを忘れないでください

Intent intent = new Intent(Main.this, Map.class); 
2
case R.id.home: 
    startActivity(new Intent(main.this, map.class)); 
    return true; 
関連する問題