|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
package com.android.settings.dualscreen; |
import android.app.ActionBar; |
import android.app.Activity; |
import android.os.Bundle; |
import android.preference.CheckBoxPreference; |
import android.preference.Preference; |
import android.preference.PreferenceActivity; |
import android.preference.PreferenceScreen; |
import android.provider.Settings; |
import android.test.PerformanceTestCase; |
import android.view.Gravity; |
import android.view.View; |
import android.widget.Switch; |
import android.widget.TextView; |
import com.android.settings.R; |
import com.android.settings.SettingsPreferenceFragment; |
public class DualScreenSettings extends SettingsPreferenceFragment { |
private static final String LOGTAG = "DualScreenSettings"; |
private static final boolean DEBUG = true; |
private void LOGD(String msg){ |
private static final String KEY_DUALSCREEN_MANUAL = "dualscreen_manual"; |
private static final String EXTRA_CHECKED = "checked"; |
private static final String EXTRA_TITLE = "title"; |
private static final String EXTRA_SUMMARY = "summary"; |
private static final String EXTRA_PREFERENCE_KEY = "preference_key"; |
private PreferenceScreen mManual; |
private DualScreenEnabler mDualScreenEnabler; |
public void onCreate(Bundle icicle) { |
addPreferencesFromResource(R.xml.dualscreen); |
mManual = (PreferenceScreen)findPreference(KEY_DUALSCREEN_MANUAL); |
Activity activity = getActivity(); |
Switch actionBarSwitch = new Switch(activity); |
if (activity instanceof PreferenceActivity) { |
PreferenceActivity preferenceActivity = (PreferenceActivity) activity; |
if (preferenceActivity.onIsHidingHeaders() |
| | !preferenceActivity.onIsMultiPane()) { |
final int padding = activity.getResources() |
R.dimen.action_bar_switch_padding); |
actionBarSwitch.setPadding(0, 0, padding, 0); |
activity.getActionBar().setDisplayOptions( |
ActionBar.DISPLAY_SHOW_CUSTOM, |
ActionBar.DISPLAY_SHOW_CUSTOM); |
activity.getActionBar().setCustomView( |
new ActionBar.LayoutParams( |
ActionBar.LayoutParams.WRAP_CONTENT, |
ActionBar.LayoutParams.WRAP_CONTENT, |
Gravity.CENTER_VERTICAL | Gravity.END)); |
mDualScreenEnabler = new DualScreenEnabler(activity, actionBarSwitch); |
if (mDualScreenEnabler != null) { |
mDualScreenEnabler.resume(); |
|
|