本文整理匯總了Java中android.support.v7.app.AppCompatDelegate類的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatDelegate類的具體用法?Java AppCompatDelegate怎麽用?Java AppCompatDelegate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AppCompatDelegate類屬於android.support.v7.app包,在下文中一共展示了AppCompatDelegate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initView
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
private void initView() {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
bt1 = findViewById(R.id.main_button1);
bt2 = findViewById(R.id.main_button2);
bt3 = findViewById(R.id.main_button3);
bt4 = findViewById(R.id.main_button4);
bt5 = findViewById(R.id.main_button5);
bt6 = findViewById(R.id.main_button6);
bt7 = findViewById(R.id.main_button7);
bt8 = findViewById(R.id.main_button8);
bt9 = findViewById(R.id.main_button9);
bt1.setOnClickListener(this);
bt2.setOnClickListener(this);
bt3.setOnClickListener(this);
bt4.setOnClickListener(this);
bt5.setOnClickListener(this);
bt6.setOnClickListener(this);
bt7.setOnClickListener(this);
bt8.setOnClickListener(this);
bt9.setOnClickListener(this);
}
示例2: changedMode
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
private void changedMode(boolean isNight, int position) {
SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, isNight);
AppCompatDelegate.setDefaultNightMode(isNight ? AppCompatDelegate.MODE_NIGHT_YES
: AppCompatDelegate.MODE_NIGHT_NO);
if (position >= 0) {
curTheme = position;
} else {
curTheme = SettingManager.getInstance().getReadTheme();
}
gvAdapter.select(curTheme);
mPageWidget.setTheme(isNight ? ThemeManager.NIGHT : curTheme);
mPageWidget.setTextColor(ContextCompat.getColor(mContext, isNight ? R.color.chapter_content_night : R.color.chapter_content_day),
ContextCompat.getColor(mContext, isNight ? R.color.chapter_title_night : R.color.chapter_title_day));
mTvBookReadMode.setText(getString(isNight ? R.string.book_read_mode_day_manual_setting
: R.string.book_read_mode_night_manual_setting));
Drawable drawable = ContextCompat.getDrawable(this, isNight ? R.drawable.ic_menu_mode_day_manual
: R.drawable.ic_menu_mode_night_manual);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
mTvBookReadMode.setCompoundDrawables(null, drawable, null, null);
ThemeManager.setReaderTheme(curTheme, mRlBookReadRoot);
}
示例3: onPrepareOptionsMenu
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
/*
app share and rate group
hide on AurPackageDetailsFragment
*/
MenuItem menuItem = menu.findItem(R.id.menu_main_app_group);
Fragment fragmentByTag = fragmentManager.findFragmentByTag(AUR_PACKAGE_DETAILS_FRAGMENT_TAG);
menuItem.setVisible(fragmentByTag == null);
// night mode
switch (AppCompatDelegate.getDefaultNightMode()) {
case AppCompatDelegate.MODE_NIGHT_AUTO:
menu.findItem(R.id.menu_main_action_night_mode_auto).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_YES:
menu.findItem(R.id.menu_main_action_night_mode_night).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_NO:
menu.findItem(R.id.menu_main_action_night_mode_day).setChecked(true);
break;
}
return true;
}
示例4: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
fragmentManager = getSupportFragmentManager();
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
int nightMode = sharedPreferences.getInt(getResources().getString(R.string.key_night_mode),
AppCompatDelegate.MODE_NIGHT_YES);
AppCompatDelegate.setDefaultNightMode(nightMode);
setTheme(R.style.AppTheme_NoActionBar);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (findViewById(R.id.main_fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
SearchFragment searchFragment = new SearchFragment();
fragmentManager.beginTransaction()
.add(R.id.main_fragment_container, searchFragment)
.commit();
}
}
示例5: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
setContentView(R.layout.activity_profesores);
//Action bar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
}
app = (App) this.getApplication();
year = app.getPublicPreferenceI(Common.GLOBAL_FILTER_YEAR);
recyclerView = (RecyclerView) findViewById(R.id.profesoresRecycler);
emptyView = (LinearLayout) findViewById(R.id.profesores_blank);
recyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getBaseContext());
recyclerView.setLayoutManager(mLayoutManager);
setYearAdapters();
setSubjectsAdapter();
updateYear(year);
}
示例6: onOptionsItemSelected
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_day:
toggleNightModeForAllActivities(AppCompatDelegate.MODE_NIGHT_NO);
return true;
case R.id.action_night:
toggleNightModeForAllActivities(AppCompatDelegate.MODE_NIGHT_YES);
return true;
case R.id.action_auto:
toggleNightModeForAllActivities(AppCompatDelegate.MODE_NIGHT_AUTO);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例7: onPreferenceChange
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
public boolean onPreferenceChange(Preference preference, Object newValue) {
switch (preference.getKey()){
case "pref_user_name":
userInFo.setTitle("尊敬的"+"“"+nickname+"”");
userInFo.setSummary("歡迎使用本應用");
break;
case"pref_theme_dark":
if((boolean)newValue) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
ActivityCollector.activities.get(0).recreate();//返回棧的首節點應該是主活動,讓它重啟
getActivity().recreate();
//Toast.makeText(getActivity(), "都說了功能還在開發中"+newValue, Toast.LENGTH_SHORT).show();
break;
}
return true;
}
示例8: simulateDayNight
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
void simulateDayNight(int currentSetting) {
final int DAY = 0;
final int NIGHT = 1;
final int FOLLOW_SYSTEM = 3;
int currentNightMode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
if (currentSetting == DAY && currentNightMode != Configuration.UI_MODE_NIGHT_NO) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
} else if (currentSetting == NIGHT && currentNightMode != Configuration.UI_MODE_NIGHT_YES) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
} else if (currentSetting == FOLLOW_SYSTEM) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
}
示例9: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
// SkinCircleImageViewManager.init(this);
// SkinMaterialManager.init(this);
// SkinConstraintManager.init(this);
// SkinCardViewManager.init(this);
// SkinFlycoTabLayoutManager.init(this);
// SkinCompatManager.init(this).loadSkin();
// SkinCompatManager.init(this)
SkinCompatManager.withoutActivity(this)
.addStrategy(new CustomSDCardLoader()) // 自定義加載策略,指定SDCard路徑
.addInflater(new SkinMaterialViewInflater()) // material design
.addInflater(new SkinConstraintViewInflater()) // ConstraintLayout
.addInflater(new SkinCardViewInflater()) // CardView v7
.addInflater(new SkinCircleImageViewInflater()) // hdodenhof/CircleImageView
.addInflater(new SkinFlycoTabLayoutInflater()) // H07000223/FlycoTabLayout
// .setSkinStatusBarColorEnable(false) // 關閉狀態欄換膚
// .setSkinWindowBackgroundEnable(false) // 關閉windowBackground換膚
// .setSkinAllActivityEnable(false) // true: 默認所有的Activity都換膚; false: 隻有實現SkinCompatSupportable接口的Activity換膚
.loadSkin();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
示例10: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Utils.DARK_THEME = Prefs.getBoolean("darktheme", false, this);
int theme;
String accent = Prefs.getString("accent_color", "pink_accent", this);
if (Utils.DARK_THEME) {
theme = sAccentDarkColors.get(accent);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
theme = sAccentColors.get(accent);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
setTheme(theme);
super.onCreate(savedInstanceState);
if (Prefs.getBoolean("forceenglish", false, this)) {
Utils.setLocale("en_US", this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(statusBarColor());
}
}
示例11: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
StethoUtil.install(this);
AppCompatDelegate.setDefaultNightMode(getSharedPreferences("settings", MODE_PRIVATE).getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO));
FontRequest fontRequest = new FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs);
EmojiCompat.Config config = new FontRequestEmojiCompatConfig(this, fontRequest);
EmojiCompat.init(config);
setupCinemaListUpdates();
}
示例12: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
prefManager = new PrefManager(this);
AppCompatImageView en = (AppCompatImageView)findViewById(R.id.langEn);
AppCompatImageView mn = (AppCompatImageView)findViewById(R.id.langMn);
AppCompatImageView cn = (AppCompatImageView)findViewById(R.id.langCn);
AppCompatImageView ru = (AppCompatImageView)findViewById(R.id.langRu);
mn.setOnClickListener(this);
en.setOnClickListener(this);
cn.setOnClickListener(this);
ru.setOnClickListener(this);
}
示例13: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
dayNightPreference = getSharedPreferences("settings", MODE_PRIVATE).getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO);
if(savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.frame, new WatchersFragment(), "watchersFragment").commit();
}
settings = getSharedPreferences("settings", MODE_PRIVATE);
}
示例14: onCreate
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
systemOut = new InterceptorOutputStream(System.out, out);
systemErr = new InterceptorOutputStream(System.err, err);
System.setOut(systemOut);
System.setErr(systemErr);
//for log cat
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
示例15: getSkinDrawableCompat
import android.support.v7.app.AppCompatDelegate; //導入依賴的package包/類
private Drawable getSkinDrawableCompat(Context context, int resId) {
if (AppCompatDelegate.isCompatVectorFromResourcesEnabled()) {
if (!isDefaultSkin) {
try {
return SkinCompatDrawableManager.get().getDrawable(context, resId);
} catch (Exception e) {
e.printStackTrace();
}
}
return AppCompatResources.getDrawable(context, resId);
} else {
return getSkinDrawable(context, resId);
}
}