當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。