Java Code Examples for android.support.v7.widget.Toolbar#setSubtitle()

The following examples show how to use android.support.v7.widget.Toolbar#setSubtitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalligraphyFactory.java    From Calligraphy with Apache License 2.0 6 votes vote down vote up
/**
 * Will forcibly set text on the views then remove ones that didn't have copy.
 *
 * @param view toolbar view.
 */
private void applyFontToToolbar(final Toolbar view) {
    final CharSequence previousTitle = view.getTitle();
    final CharSequence previousSubtitle = view.getSubtitle();
    // The toolbar inflates both the title and the subtitle views lazily but luckily they do it
    // synchronously when you set a title and a subtitle programmatically.
    // So we set a title and a subtitle to something, then get the views, then revert.
    view.setTitle("uk.co.chrisjenx.calligraphy:toolbar_title");
    view.setSubtitle("uk.co.chrisjenx.calligraphy:toolbar_subtitle");

    // Iterate through the children to run post inflation on them
    final int childCount = view.getChildCount();
    for (int i = 0; i < childCount; i++) {
        onViewCreated(view.getChildAt(i), view.getContext(), null);
    }
    // Remove views from view if they didn't have copy set.
    view.setTitle(previousTitle);
    view.setSubtitle(previousSubtitle);
}
 
Example 2
Source File: BaseHoldBackActivity.java    From FlowGeek with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View view;

    setContentView(view = getLayoutInflater().inflate(onBindLayout(), null));

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);

    mToolbar.setTitle("");
    mToolbar.setSubtitle(onSetTitle());
    mToolbar.setNavigationIcon(R.mipmap.icon_back);
    setSupportActionBar(mToolbar);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
 
Example 3
Source File: BaseToolbarActivity.java    From MarkdownEditors with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化actionbar
 *
 * @param toolbar the mToolbar
 */
private void initActionBar(Toolbar toolbar) {
    if (!Check.isEmpty(getSubtitleString())) {
        toolbar.setSubtitle(getSubtitleString());
    }
    if (getTitleString() != null) {
        toolbar.setTitle(getTitleString());
    }

    setSupportActionBar(toolbar);
    if (hasBackButton()) {//如果需要返回按钮
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true);

    }
}
 
Example 4
Source File: CrashReporterActivity.java    From CrashReporter with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.crash_reporter_activity);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getString(R.string.crash_reporter));
    toolbar.setSubtitle(getApplicationName());
    setSupportActionBar(toolbar);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 5
Source File: MainActivity.java    From PracticeCode with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toast.makeText(this, "喵佩罗娜!", Toast.LENGTH_SHORT).show();
    XSCHelper.getInstance().loadProjListFromLocal(this);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.LTGRAY);
    toolbar.setSubtitle(UserInfoBasic.nickName);
    toolbar.setSubtitleTextColor(Color.LTGRAY);
    setSupportActionBar(toolbar);

    menuFadeAdapter = new MenuFadeAdapter(toolbar);
    menuFadeAdapter.setColor(ToolbarColor);
    menuFadeAdapter.setMaxAlpha(255);
    menuFadeAdapter.saveAndNotifySettingsChanged();

    toolBarFadeAdapter = new ToolBarFadeAdapter(toolbar);
    toolBarFadeAdapter.setColor(ToolbarColor);
    toolBarFadeAdapter.setAlpha(255, 0);
    toolBarFadeAdapter.setMenuAdapter(menuFadeAdapter);
    toolBarFadeAdapter.saveAndNotifySettingsChanged();

    initWidgets();
    initSettings();
}
 
Example 6
Source File: LockedCompatActivity.java    From LolliPin with MIT License 5 votes vote down vote up
private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.id_toolbar);
    setSupportActionBar(toolbar);

    toolbar.setTitle("Title");
    toolbar.setTitleTextColor(getResources().getColor(android.R.color.white));
    toolbar.setSubtitle("SubTitle");
    toolbar.setSubtitleTextColor(getResources().getColor(android.R.color.white));
    toolbar.setLogo(R.drawable.ic_launcher);
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_36dp);
}
 
Example 7
Source File: AppListFragment.java    From AppPlus with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(initLayout(), container, false);
    Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    toolbar.setTitle(R.string.app_name_inner);

    toolbar.setSubtitle(getTitleString(mType));

    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    ab.setDisplayHomeAsUpEnabled(true);

    setupSwipeLayout(rootView);
    setupRecyclerView(rootView);
    return rootView;
}
 
Example 8
Source File: AppFileListFragment.java    From AppPlus with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(initLayout(), container, false);
    Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    toolbar.setTitle(R.string.app_name);

    toolbar.setSubtitle(R.string.tab_exported);

    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    ab.setDisplayHomeAsUpEnabled(true);

    setupSwipeLayout(rootView);
    setupRecyclerView(rootView);

    return rootView;
}
 
Example 9
Source File: MainActivity.java    From httplite with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        mToolbar.setSubtitle("点击左侧机器人切换");

        mToolbar.setNavigationIcon(R.mipmap.ic_launcher);
        mToolbar.setNavigationOnClickListener(this);

        List<LeftMenuAdapter.MenuItem> list = new ArrayList<>();
        list.add(new LeftMenuAdapter.MenuItem("自定义请求", RequestFrag.class));
        list.add(new LeftMenuAdapter.MenuItem("下载上传管理", DownloadFrag.class));
        list.add(new LeftMenuAdapter.MenuItem("Retrofit", RetrofitFrag.class));
        list.add(new LeftMenuAdapter.MenuItem("获取文件列表", GetFrag.class));
        list.add(new LeftMenuAdapter.MenuItem("列表选择上传", PostFrag.class));
        leftMenuAdapter = new LeftMenuAdapter(list,this);
        mRecyclerView.addItemDecoration(new RecycleViewDivider(this,LinearLayoutManager.HORIZONTAL));
        mRecyclerView.setAdapter(leftMenuAdapter);
        EventBus.getDefault().register(this);
        onItemClick(list.get(0));
//        TestRetrofit.testCustom(App.httpLite(this));
//        TestRetrofit.testFilter(App.httpLite(this));
//        TestRetrofit.testSampleApi(App.httpLite(this));
        Util.isSubType(new Clazz<Result<RequestInfo>>(){}.type(),Result.class);
    }
 
Example 10
Source File: EncodeAllProcessTextActivity.java    From text_converter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CharSequence text = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
    if (text != null) {
        setContentView(R.layout.activity_process_text);

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        setTitle(R.string.encode);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setSubtitle(text);

        TextView txtMessage = findViewById(R.id.txt_message);
        if (Premium.isPremium(this)) {
            txtMessage.setVisibility(View.GONE);
        } else {
            txtMessage.setText(getString(R.string.chance_remaining, getChanceRemaining()));
            txtMessage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Premium.upgrade(EncodeAllProcessTextActivity.this);
                }
            });
        }

        String input = text.toString();
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.content, EncodeAllFragment.newInstance(input, true)).commit();
    } else {
        finish();
    }
}
 
Example 11
Source File: BarcodeEncodedActivity.java    From text_converter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_barcode);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.tab_title_barcode);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String text = getIntent().getStringExtra("data");
    if (text == null) text = "";
    toolbar.setSubtitle(text);

    ViewPager viewPager = findViewById(R.id.view_pager);
    viewPager.setAdapter(new BarcodeEncodedPagerAdapter(getSupportFragmentManager(), text));
    viewPager.setOffscreenPageLimit(3);
    viewPager.setCurrentItem(8); //barcode
    ((TabLayout) findViewById(R.id.tab_layout)).setupWithViewPager(viewPager);

    if (Premium.isPremium(this)){
        View containerAd = findViewById(R.id.container_ad);
        if (containerAd != null) containerAd.setVisibility(View.GONE);
    }else {
        AdsManager.loadAds(this, findViewById(R.id.container_ad), findViewById(R.id.ad_view));
    }
}
 
Example 12
Source File: BaseActivity.java    From Android-skin-support with MIT License 5 votes vote down vote up
protected void initToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Title");
    toolbar.setSubtitle("Subtitle");
    toolbar.setNavigationIcon(R.drawable.ic_settings_black_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
        }
    });
    toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.ic_camera_24dp));
}
 
Example 13
Source File: MainActivity.java    From Android-Skin with MIT License 5 votes vote down vote up
protected void initToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("AndroidSkin");
    toolbar.setSubtitle("Welcome to AndroidSkin");
    toolbar.setNavigationIcon(R.drawable.apk_all_bottomfind);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, SkinSelectActivity.class));
        }
    });
    toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.apk_all_bottomfind));
}
 
Example 14
Source File: MainActivity.java    From DarkCalculator with MIT License 5 votes vote down vote up
private void initToolBar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(null);
    toolbar.setSubtitle("科学计算");
    ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
}
 
Example 15
Source File: StylishProcessTextActivity.java    From text_converter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CharSequence text = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
    if (text != null) {
        setContentView(R.layout.activity_process_text);

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        setTitle(R.string.process_text_title_stylish_it);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setSubtitle(text);

        TextView txtMessage = findViewById(R.id.txt_message);
        if (Premium.isPremium(this)) {
            txtMessage.setVisibility(View.GONE);
        } else {
            txtMessage.setText(getString(R.string.chance_remaining, getChanceRemaining()));
            txtMessage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Premium.upgrade(StylishProcessTextActivity.this);
                }
            });
        }


        String input = text.toString();
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.content, StylistProcessTextFragment.newInstance(input)).commit();
    } else {
        finish();
    }
}
 
Example 16
Source File: DecodeAllProcessTextActivity.java    From text_converter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CharSequence text = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
    if (text != null) {
        setContentView(R.layout.activity_process_text);

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle(R.string.decode);
        toolbar.setSubtitle(text);

        TextView txtMessage = findViewById(R.id.txt_message);
        if (Premium.isPremium(this)) {
            txtMessage.setVisibility(View.GONE);
        } else {
            txtMessage.setText(getString(R.string.chance_remaining, getChanceRemaining()));
            txtMessage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Premium.upgrade(DecodeAllProcessTextActivity.this);
                }
            });
        }

        String input = text.toString();
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.content, DecodeAllFragment.newInstance(input, true)).commit();
    } else {
        finish();
    }
}
 
Example 17
Source File: Profile_EditorV2.java    From HAPP with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile__editor);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarProfileEditor);
    sdfTimeDisplay = new SimpleDateFormat("HH:mm", getResources().getConfiguration().locale);
    recyclerView = (RecyclerView) findViewById(R.id.profile_list);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        profile = extras.getString("PROFILE");
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainApp.instance());

        if (profile != null) {
            profileName             = tools.getActiveProfileName(profile, prefs, this);
            timeSlotsDefaultRange   = tools.getTimeSlotsDefaultRange(profile, prefs);

            switch (profile) {
                case Constants.profile.ISF_PROFILE:
                    profileUnit             = tools.bgUnitsFormat();
                    toolbar.setTitle(getString(R.string.prefs_isf_profile) + ": " + profileName);
                    toolbar.setSubtitle(R.string.prefs_isf_profile_summary);
                    break;
                case Constants.profile.BASAL_PROFILE:
                    profileUnit             = "units";
                    toolbar.setTitle(getString(R.string.prefs_basal_profile) + ": " + profileName);
                    toolbar.setSubtitle(R.string.prefs_basal_profile_summary);
                    break;
                case Constants.profile.CARB_PROFILE:
                    profileUnit             = "grams";
                    toolbar.setTitle(getString(R.string.prefs_carb_profile) + ": " + profileName);
                    toolbar.setSubtitle(R.string.prefs_carb_profile_summary);
                    break;
                default:
                    Log.e(TAG, "Unknown profile: " + profile + ", not sure what profile to load");
                    Crashlytics.log(1,TAG,"Unknown profile: " + profile + ", not sure what profile to load");
                    this.finish();
            }

            timeSpansList           = tools.getActiveProfile(profile, prefs);
            setProfile();

        } else {
            Log.e(TAG, "No Extra String 'PROFILE' passed, not sure what profile to load");
            Crashlytics.log(1,TAG,"No Extra String 'PROFILE' passed, not sure what profile to load");
            this.finish();
        }
    } else {
        Log.e(TAG, "No profile Extra passed, not sure what profile to load");
        Crashlytics.log(1,TAG,"No profile Extra passed, not sure what profile to load");
        this.finish();
    }

    setSupportActionBar(toolbar);
}
 
Example 18
Source File: ModuleActivity.java    From SimpleSmsRemote with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_configure_control_module);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Resources res = getResources();

    String controlModuleId = getIntent().getStringExtra("controlActionId");
    module = Module.getFromId(controlModuleId);
    if (module == null) {
        finish();
        return;
    }

    if(DataManager.getUserData() == null)
    {
        // Return to main activity.
        startActivity(new Intent(this, MainActivity.class));
    }
    userData = module.getUserData();

    isModuleEnabled = module.isEnabled();
    toolbar.setTitle(R.string.title_activity_configure_control_action);

    if (module.getTitleRes() != -1) {
        toolbar.setSubtitle(module.getTitleRes());
    }

    if (module.getDescriptionRes() != -1) {
        ((TextView) findViewById(R.id.textView_description)).setText(
                module.getDescriptionRes());
    }

    ListView commandsListView = (ListView) findViewById(R.id.listView_commands);
    CommandSyntaxDescListAdapter commandsListAdapter = new CommandSyntaxDescListAdapter(this,
            module.getCommands());
    commandsListView.setAdapter(commandsListAdapter);
    UIUtils.SetListViewHeightBasedOnItems(commandsListView);

    if (module.getParamInfoRes() != -1) {
        ((TextView) findViewById(R.id.textView_command_parameter_info))
                .setText(module.getParamInfoRes());
    } else {
        findViewById(R.id.textView_command_parameter_info_title).setVisibility(View.GONE);
        findViewById(R.id.textView_command_parameter_info).setVisibility(View.GONE);
    }

    TextView compatibilityTextView = (TextView) findViewById(R.id.textView_compatibility_info);
    Button buttonChangeEnabled = (Button) findViewById(R.id.button_change_enabled);

    buttonChangeEnabled.setText(!isModuleEnabled ? R.string.enable_module
            : R.string.disable_module);

    findViewById(R.id.imageButton_command_info).setOnClickListener(this);

    if (module.isCompatible(this)) {
        compatibilityTextView.setText(R.string.compatible);
        compatibilityTextView.setTextColor(res.getColor(R.color.colorSuccess));
        buttonChangeEnabled.setOnClickListener(this);
    } else {
        compatibilityTextView.setText(R.string.incompatible);
        compatibilityTextView.setTextColor(res.getColor(R.color.colorError));
        buttonChangeEnabled.setVisibility(View.INVISIBLE);
    }

    if (isModuleEnabled) {
        moduleSettings = userData.getSettings();

        findViewById(R.id.card_user_settings).setVisibility(View.VISIBLE);
        findViewById(R.id.textView_user_settings_title).setVisibility(View.VISIBLE);

        grantedPhones = userData.getGrantedPhones();
        if (grantedPhones.isEmpty())
            grantedPhones.add("");

        grantedPhonesListView = (ListView) findViewById(R.id.listView_granted_phones);
        grantedPhonesListAdapter = new GrantedPhonesEditableListAdapter(this, grantedPhones,
                grantedPhonesListView);
        grantedPhonesListView.setScrollContainer(false);
        grantedPhonesListView.setAdapter(grantedPhonesListAdapter);
        UIUtils.SetListViewHeightBasedOnItems(grantedPhonesListView);

        FloatingActionButton addPhoneFab = (FloatingActionButton) findViewById(R.id.fab_add_phone);
        addPhoneFab.setOnClickListener(this);
    }
}
 
Example 19
Source File: PostFragment.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.activity_toolbar, container, false);
    ViewGroup contentPanel = (ViewGroup) view.findViewById(R.id.content_panel);
    ViewGroup contentView = (ViewGroup) inflater.inflate(R.layout.fragment_post, contentPanel, true);

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    // I like hardcode
    mToolbar.setSubtitle("A岛·adnmb.com");
    if (mId != null) {
        mToolbar.setTitle(mSite.getPostTitle(getContext(), mId));
    } else {
        mToolbar.setTitle(getString(R.string.thread));
    }
    mToolbar.setNavigationIcon(DrawableManager.getDrawable(getContext(), R.drawable.v_arrow_left_dark_x24));
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFragmentHost().finishFragment(PostFragment.this);
        }
    });
    mToolbar.inflateMenu(R.menu.activity_post);
    mToolbar.setOnMenuItemClickListener(this);

    mContentLayout = (ContentLayout) contentView.findViewById(R.id.content_layout);
    mRecyclerView = mContentLayout.getRecyclerView();

    mReplyHelper = new ReplyHelper();
    mReplyHelper.setEmptyString(getString(R.string.not_found));
    mContentLayout.setHelper(mReplyHelper);
    if (Settings.getFastScroller()) {
        mContentLayout.showFastScroll();
    } else {
        mContentLayout.hideFastScroll();
    }

    mReplyAdapter = new ReplyAdapter();
    mRecyclerView.setAdapter(mReplyAdapter);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(
            getContext(), ResourcesUtils.getAttrBoolean(getContext(), R.attr.dark)));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.hasFixedSize();
    mOnScrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (RecyclerView.SCROLL_STATE_DRAGGING == newState) {
                pauseHolders();
            } else if (RecyclerView.SCROLL_STATE_IDLE == newState) {
                resumeHolders();
            }
        }
    };
    mRecyclerView.addOnScrollListener(mOnScrollListener);

    mOpColor = getResources().getColor(R.color.colorAccent);

    // Refresh
    mReplyHelper.firstRefresh();

    Messenger.getInstance().register(Constants.MESSENGER_ID_REPLY, this);
    Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this);

    isLoaded = false;

    return view;
}
 
Example 20
Source File: ToolbarActivity.java    From AndroidViewDemo with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_toolbar);

    Toolbar toolbar = (Toolbar) findViewById(R.id.ac_toolbar_toolbar);

    // 设置主标题及其颜色
    toolbar.setTitle("AndroidViewDemo");
    toolbar.setTitleTextColor(Color.WHITE);

    // 设置次标题及其颜色
    toolbar.setSubtitle("AigeStudio");
    toolbar.setSubtitleTextColor(Color.LTGRAY);

    // 设置导航按钮
    toolbar.setNavigationIcon(R.drawable.menu);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(ToolbarActivity.this, "Navigation", Toast.LENGTH_SHORT).show();
        }
    });
    // 设置Logo图标
    toolbar.setLogo(R.mipmap.ic_launcher);

    // 设置菜单及其点击监听
    toolbar.inflateMenu(R.menu.ac_toolbar_menu);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            String result = "";
            switch (item.getItemId()) {
                case R.id.ac_toolbar_copy:
                    result = "Copy";
                    break;
                case R.id.ac_toolbar_cut:
                    result = "Cut";
                    break;
                case R.id.ac_toolbar_del:
                    result = "Del";
                    break;
                case R.id.ac_toolbar_edit:
                    result = "Edit";
                    break;
                case R.id.ac_toolbar_email:
                    result = "Email";
                    break;
            }
            Toast.makeText(ToolbarActivity.this, result, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}