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