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


Java ExtendedEditText.setHint方法代码示例

本文整理汇总了Java中com.android.launcher3.ExtendedEditText.setHint方法的典型用法代码示例。如果您正苦于以下问题:Java ExtendedEditText.setHint方法的具体用法?Java ExtendedEditText.setHint怎么用?Java ExtendedEditText.setHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.launcher3.ExtendedEditText的用法示例。


在下文中一共展示了ExtendedEditText.setHint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFinishInflate

import com.android.launcher3.ExtendedEditText; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    // This is a focus listener that proxies focus from a view into the list view.  This is to
    // work around the search box from getting first focus and showing the cursor.
    getContentView().setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                mAppsRecyclerView.requestFocus();
            }
        }
    });

    mSearchContainer = findViewById(R.id.search_container);

    if(Utilities.isAllowNightModePrefEnabled(getContext())) {
        mSearchContainer.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.night_color));
    }else{
        if(Utilities.getDrawerBackgroundPrefEnabled(getContext()) != -1){
            mSearchContainer.setBackgroundColor(Utilities.getDrawerBackgroundPrefEnabled(getContext()));
        }else {
            mSearchContainer.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.white));
        }
    }
    mSearchInput = (ExtendedEditText) findViewById(R.id.search_box_input);

    // Update the hint to contain the icon.
    // Prefix the original hint with two spaces. The first space gets replaced by the icon
    // using span. The second space is used for a singe space character between the hint
    // and the icon.
    SpannableString spanned = new SpannableString("  " + mSearchInput.getHint());
    spanned.setSpan(new TintedDrawableSpan(getContext(), R.drawable.ic_allapps_search),
            0, 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
    mSearchInput.setHint(spanned);

    mSearchContainerOffsetTop = getResources().getDimensionPixelSize(
            R.dimen.all_apps_search_bar_margin_top);

    mElevationController = Utilities.ATLEAST_LOLLIPOP
            ? new HeaderElevationController.ControllerVL(mSearchContainer)
            : new HeaderElevationController.ControllerV16(mSearchContainer);

    // Load the all apps recycler view
    mAppsRecyclerView = (AllAppsRecyclerView) findViewById(R.id.apps_list_view);
    mAppsRecyclerView.setApps(mApps);
    mAppsRecyclerView.setLayoutManager(mLayoutManager);
    mAppsRecyclerView.setAdapter(mAdapter);
    mAppsRecyclerView.setHasFixedSize(true);
    mAppsRecyclerView.addOnScrollListener(mElevationController);
    mAppsRecyclerView.setElevationController(mElevationController);

    if (mItemDecoration != null) {
        mAppsRecyclerView.addItemDecoration(mItemDecoration);
    }

    FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mAppsRecyclerView);
    mAppsRecyclerView.addItemDecoration(focusedItemDecorator);
    mAppsRecyclerView.preMeasureViews(mAdapter);
    mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());

    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
        getRevealView().setVisibility(View.VISIBLE);
        getContentView().setVisibility(View.VISIBLE);
        getContentView().setBackground(null);
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:69,代码来源:AllAppsContainerView.java

示例2: onFinishInflate

import com.android.launcher3.ExtendedEditText; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    // This is a focus listener that proxies focus from a view into the list view.  This is to
    // work around the search box from getting first focus and showing the cursor.
    getContentView().setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                mAppsRecyclerView.requestFocus();
            }
        }
    });

    mSearchContainer = findViewById(R.id.search_container);
    mSearchInput = (ExtendedEditText) findViewById(R.id.search_box_input);

    // Update the hint to contain the icon.
    // Prefix the original hint with two spaces. The first space gets replaced by the icon
    // using span. The second space is used for a singe space character between the hint
    // and the icon.
    SpannableString spanned = new SpannableString("  " + mSearchInput.getHint());
    spanned.setSpan(new TintedDrawableSpan(getContext(), R.drawable.ic_allapps_search),
            0, 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
    mSearchInput.setHint(spanned);

    mSearchContainerOffsetTop = getResources().getDimensionPixelSize(
            R.dimen.all_apps_search_bar_margin_top);

    mElevationController = Utilities.ATLEAST_LOLLIPOP
            ? new HeaderElevationController.ControllerVL(mSearchContainer)
            : new HeaderElevationController.ControllerV16(mSearchContainer);

    // Load the all apps recycler view
    mAppsRecyclerView = (AllAppsRecyclerView) findViewById(R.id.apps_list_view);
    mAppsRecyclerView.setApps(mApps);
    mAppsRecyclerView.setLayoutManager(mLayoutManager);
    mAppsRecyclerView.setAdapter(mAdapter);
    mAppsRecyclerView.setHasFixedSize(true);
    mAppsRecyclerView.addOnScrollListener(mElevationController);
    mAppsRecyclerView.setElevationController(mElevationController);

    if (mItemDecoration != null) {
        mAppsRecyclerView.addItemDecoration(mItemDecoration);
    }

    FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mAppsRecyclerView);
    mAppsRecyclerView.addItemDecoration(focusedItemDecorator);
    mAppsRecyclerView.preMeasureViews(mAdapter);
    mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());

    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
        getRevealView().setVisibility(View.VISIBLE);
        getContentView().setVisibility(View.VISIBLE);
        getContentView().setBackground(null);
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:59,代码来源:AllAppsContainerView.java


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