0

我正在尝试Sherlock ActionBar通过扩展我Activity的 to来使用,Sherlock Activity但我在getSupportActionBar()which return上收到以下错误null

05-16 10:45:22.537: E/AndroidRuntime(20631): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tzoomers.birthdaysdiary/com.tzoomers.birthdaysdiary.SyncActivity}: java.lang.NullPointerException
05-16 10:45:22.537: E/AndroidRuntime(20631):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
05-16 10:45:22.537: E/AndroidRuntime(20631):    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1991)
05-16 10:45:22.537: E/AndroidRuntime(20631):    at 
.
.
..

05-16 10:45:22.537: E/AndroidRuntime(20631): Caused by: java.lang.NullPointerException
05-16 10:45:22.537: E/AndroidRuntime(20631):    at com.tzoomers.birthdaysdiary.SyncActivity.onCreate(SyncActivity.java:38)
05-16 10:45:22.537: E/AndroidRuntime(20631):    at android.app.Activity.performCreate(Activity.java:4531)
05-16 10:45:22.537: E/AndroidRuntime(20631):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)

我正在设置App Themeandroid:theme="@style/Theme.Sherlock.Light.DarkActionBar". 谁能告诉我为什么我NullPointerExceptiongetSupportActionBar()进去SherlockActivity

活动是:

package com.tzoomers.birthdaysdiary;

import com.actionbarsherlock.app.SherlockActivity;
import com.tzoomers.controller.BirthdaysClickOListener;
import android.os.Bundle;
import android.widget.Button;

public class SyncActivity extends SherlockActivity{
    Button importFromFacebookButton, sendToDeviceButton, receiveFromDeviceButton, saveToSdCardButton, loadFromSDCardButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_sync_activity);

//      requestWindowFeature(Window.FEATURE_ACTION_BAR);

        importFromFacebookButton  = (Button) findViewById(R.id.importFacebookButton);
        sendToDeviceButton  = (Button) findViewById(R.id.sendToDeviceButton);
        receiveFromDeviceButton  = (Button) findViewById(R.id.receiveFromDeviceButton);

        importFromFacebookButton.setOnClickListener(
                new BirthdaysClickOListener(ActionType.IMPORT_FACEBOOK_CONTACTS, this));
        sendToDeviceButton.setOnClickListener(
                new BirthdaysClickOListener(ActionType.SEND_TO_DEVICE, this));
        receiveFromDeviceButton.setOnClickListener(
                new BirthdaysClickOListener(ActionType.RECEIVE_FROM_DEVICE, this));

//      getActionBar().setDisplayHomeAsUpEnabled(true);
//      getSupportActionBar().se
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    }

    @Override
    public boolean onOptionsItemSelected(
            com.actionbarsherlock.view.MenuItem item) {
        // TODO Auto-generated method stub
        return super.onOptionsItemSelected(item);
    }

    public enum ActionType
    {
        IMPORT_FACEBOOK_CONTACTS, SEND_TO_DEVICE, RECEIVE_FROM_DEVICE, SAVE_TO_SDCARD, LOAD_FROM_SDCARD
    }
}

提前致谢。

问候,

4

0 回答 0