我試圖讓我的菜單充氣器鏈接到我的佈局文件,但當應用程序啓動,我點擊菜單,然後選擇菜單選項它崩潰程序。它說,它無法找到活動推出:安卓菜單Inflater錯誤
錯誤在Eclipse的logcat:
10月1日至1日:24:38.799:E/AndroidRuntime(30359):了java.lang.RuntimeException:無法實例活動ComponentInfo { com.menu/com.menu.AboutUs}:java.lang.ClassNotFoundException:com.menu.AboutUs in loader dalvik.system.PathClassLoader [/data/app/com.menu-1.apk]
Main Code:
package menu;
import com.menu.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
public class testActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// TODO Auto-generated method stub
super.onCreateOptionsMenu(menu);
MenuInflater blowUp = getMenuInflater();
blowUp.inflate(R.menu.new_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()){
case R.id.aboutUs:
Intent i = new Intent("menu.ABOUT");
startActivity(i);
break;
case R.id.settings:
break;
}
return false;
}
清單代碼:
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name="menu.testActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AboutUs"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog">
<intent-filter >
<action android:name="menu.ABOUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
about.xml代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:text="Why dosent this work??????????????????????? "
android:title="About Us"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
我將感激感激幫助...謝謝
有你的意圖增加了一個行動「menu.ABOUT」過濾一個您想要在菜單選項點擊開始的活動?也可以嘗試刪除'。'在menu.ABOUT中,並使用menu_ABOUT – 2012-01-01 17:38:49
,但菜單是包,我只是decalring關於所在的位置沒有? – user1121322 2012-01-01 17:46:23