操作栏兼容性已添加到支持库,修订版18中.它现在具有ActionBarActivity用于在旧版Android上使用操作栏创建活动的类.
有没有办法从支持库添加Action Bar PreferenceActivity?
以前我用ActionBarSherlock,它有SherlockPreferenceActivity.
android preferenceactivity android-actionbar android-support-library
有没有办法在首选项屏幕的底部添加一个按钮,并在滚动时使它们正常工作?
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
public class OptionsActivity extends PreferenceActivity {
private ListPreference mListPreference;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
addPreferencesFromResource(R.xml.options);
mListPreference = (ListPreference) findPreference("listpreference");
mListPreference.setPersistent(false);
}
}
Exception Stacktrace is given below:
01-27 12:35:51.920: ERROR/AndroidRuntime(615): FATAL EXCEPTION: main
01-27 12:35:51.920: ERROR/AndroidRuntime(615): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.game/com.android.game.OptionsActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
01-27 12:35:51.920: ERROR/AndroidRuntime(615): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-27 12:35:51.920: …Run Code Online (Sandbox Code Playgroud) android ×3