2

我已经创建了一个活动,现在我正在尝试向eventListener按钮添加一个:

但是当我切换AddEntryActivitySuperNotCalledException(). 非常感谢任何帮助!

public class AddEntryActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_entry);
    ImageButton test = (ImageButton) findViewById(R.id.mg_add_entry_button_save);
    ...

这是我的 activity_add_entry.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity$PlaceholderFragment"
    android:background="@drawable/radialback">

    <LinearLayout
        android:orientation="vertical"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:id="@+id/mg_overview"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_above="@+id/mg_menu_bar">

        <EditText
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:inputType="numberDecimal">
        </EditText>

        <EditText
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:inputType="date"/>

        <Spinner
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:id="@+id/mg_add_entry_spinner_categories"
            android:entries="@array/basic_categories_array"
            android:prompt="@string/abc_activity_chooser_view_see_all"></Spinner>

        <Button
            android:id="@+id/mg_add_entry_button_save"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="@string/mg_save"/>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/mg_menu_bar"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true">
        <ImageButton
            android:id="@+id/mg_menu_button_add_entry"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:src="@drawable/abc_ic_go"/>
    </LinearLayout>

</RelativeLayout>
4

1 回答 1

0

很难说没有看到你的 logcat,但很可能你正在覆盖上一个活动类中的某些方法(例如onPauseor onStop),并且你错过了对 super.- 的调用

@Override
public void onPause() {
    super.onPause();
    // Your stuff
}
于 2013-11-03T20:58:50.000 回答