특정 활동에 자동으로 생성 된 OnCreateOptionsMenu
은 기기의 옵션 버튼을 누르면 충돌합니다. 동일한 작업이 다른 작업에 액세스하는 동안 앱을 중단시키지 않습니다. 같은 앱.OnOptionsMenu가 앱을 충돌하게합니다.
logcat
의 불만 중 하나는 NPE
이며이 오류의 원인을 알 수 없습니다. 모든 XML 파일이 정확합니다.
자바 코드 :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFormat(PixelFormat.TRANSPARENT);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.add_new_location_activity);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.addnewloaction_optionsmenu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
add_new_location_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@color/titleBackGroundColor">
<RelativeLayout
android:id="@+id/RelativeLayout00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal">
<TextView
android:id="@+id/addLocationActivityTitleID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="@dimen/titlesTextSize"
android:text="@string/addLocationActivityTitle"
android:textColor="@color/titleColor">
</TextView>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginTop"
android:background="@color/bodyBackGroundColor">
<TextView
android:id="@+id/editTextLabelID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/editTextLabel"
android:gravity="left"
android:textSize="@dimen/labelsTextSizes"
android:textColor="@color/contentsColor">"
</TextView>
<EditText
android:id="@+id/editTextID"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_toRightOf="@+id/editTextLabelID"
android:textColor="@color/contentsColor"
android:inputType="text">
</EditText>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
매니페스트 파일 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.meetingpointlocator_03"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.meetingpointlocator_03.Intro"
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.example.meetingpointlocator_03.MainMenuActivity"
android:label="@string/title_activity_mpl" >
</activity>
<activity
android:name="com.example.meetingpointlocator_03.AddNewLocationActivity"
android:label="@string/title_activity_add_new_location" >
</activity>
</application>
</manifest>
로그 캣 출력 :
05-11 23:27:28.591: E/InputEventSender(2636): Exception dispatching finished signal.
05-11 23:27:28.596: E/MessageQueue-JNI(2636): Exception in MessageQueue callback:
handleReceiveCallback
05-11 23:27:28.626: E/MessageQueue-JNI(2636): java.lang.NullPointerException
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at
android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:287)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at
android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at android.support.v7.app.ActionBarActivityDelegate.getMenuInflater(ActionBarActivityDelegate. java:98)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at
android.support.v7.app.ActionBarActivity.getMenuInflater(ActionBarActivity.java:71)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at
com.example.meetingpointlocator_03.AddNewLocationActivity.onCreateOptionsMenu(AddNewLocatio nActivity.java:35)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at
android.app.Activity.onCreatePanelMenu(Activity.java:2578)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at
android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:232)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDele gateICS.java:147)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:199)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu (ActionBarActivityDelegateICS.java:285)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:507)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:964)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1670)
05-11 23:27:28.626: E/MessageQueue-JNI(2636): at com. android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2227)
활동 코드 게시 – Libin
업데이트를 참조하십시오. –
이 활동의 테마는 무엇입니까? 당신은 매니 페스트 XML을 게시 할 수 있습니까 – Libin