当前位置: 首页>>代码示例>>Java>>正文


Java AppCompatDelegate类代码示例

本文整理汇总了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);
}
 
开发者ID:zzyandzzy,项目名称:SuperToast,代码行数:27,代码来源:MainActivity.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ReadActivity.java

示例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;
}
 
开发者ID:rascarlo,项目名称:AURdroid,代码行数:24,代码来源:MainActivity.java

示例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();
    }
}
 
开发者ID:rascarlo,项目名称:AURdroid,代码行数:23,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:27,代码来源:ProfesoresActivity.java

示例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);
    }
}
 
开发者ID:swustmuzi,项目名称:PNightMode,代码行数:17,代码来源:BaseAppCompatActivity.java

示例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;
}
 
开发者ID:MoonRiser,项目名称:MaterialLearning,代码行数:23,代码来源:PrefFragment.java

示例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);
    }
}
 
开发者ID:techstar-cloud,项目名称:techstar-org,代码行数:19,代码来源:AboutUsActivity.java

示例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);
    }
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:24,代码来源:App.java

示例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());
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:27,代码来源:BaseActivity.java

示例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();
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:18,代码来源:MovieNotifierApp.java

示例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);
}
 
开发者ID:techstar-cloud,项目名称:techstar-shop,代码行数:19,代码来源:ActivitySplashScreen.java

示例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);
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:17,代码来源:MainActivity.java

示例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);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:12,代码来源:JavaApplication.java

示例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);
    }
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:15,代码来源:SkinCompatResources.java


注:本文中的android.support.v7.app.AppCompatDelegate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。