當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageButton.getDrawable方法代碼示例

本文整理匯總了Java中android.widget.ImageButton.getDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageButton.getDrawable方法的具體用法?Java ImageButton.getDrawable怎麽用?Java ImageButton.getDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageButton的用法示例。


在下文中一共展示了ImageButton.getDrawable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import android.widget.ImageButton; //導入方法依賴的package包/類
private void init(AttributeSet attrs, int defStyle) {
    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.lingju, defStyle, 0);
    LayoutInflater.from(getContext()).inflate(R.layout.search_online_box, this);
    mLlRoot = findViewById(R.id.ll_root);
    edit = (EditText) findViewById(R.id.sob_search_edit);
    stateBt = (ImageButton) findViewById(R.id.sob_state_bt);
    animate = AnimationUtils.loadAnimation(getContext(), R.anim.start_up_loading);
    animate.setInterpolator(new LinearInterpolator());
    drawable = (LevelListDrawable) stateBt.getDrawable();
    edit.addTextChangedListener(searhWatcher);
    edit.setOnEditorActionListener(editorActionListener);
    edit.setOnClickListener(editorClickListener);
    stateBt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (stateBt.getVisibility() == View.VISIBLE && drawable.getLevel() == 1) {
                edit.setText("");
                stateBt.setVisibility(View.INVISIBLE);
            }
        }
    });
    edit.setHint(a.getString(R.styleable.lingju_hint));
    // edit.setHintTextColor(getResources().getColor(R.color.navi_search_box_color));
    edit.setHintTextColor(a.getColor(R.styleable.lingju_hintColor, getResources().getColor(R.color.navi_search_box_color)));
    edit.setTextColor(a.getColor(R.styleable.lingju_textColor, getResources().getColor(R.color.ksw_md_solid_disable)));
    mLlRoot.setBackgroundColor(a.getColor(R.styleable.lingju_search_background, getResources().getColor(R.color.green_style)));
    //edit.setTextSize(a.getFloat(com.android.internal.R.styleable.TextView_textSize,12));

    a.recycle();
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:34,代碼來源:RealTimeUpdateSearchBox.java

示例2: onSearchViewQueryChange

import android.widget.ImageButton; //導入方法依賴的package包/類
private void onSearchViewQueryChange(final String query, final ImageButton navigateBack,
                               final TextView results) {
    final boolean isDarkThemeSelected = ThemeUtils.isDarkThemeSelected(this);
    final Drawable drawable;

    if (!TextUtils.isEmpty(query)) {
        if (isDarkThemeSelected) {
            drawable = getDrawable(R.drawable.ic_clear_white_24dp);
        } else {
            drawable = getDrawable(R.drawable.ic_clear_black_24dp);
        }
    } else {
        if (results.getVisibility() != View.INVISIBLE) {
            results.setVisibility(View.INVISIBLE);
        }

        if (isDarkThemeSelected) {
            drawable = getDrawable(R.drawable.ic_arrow_back_white_24dp);
        } else {
            drawable = getDrawable(R.drawable.ic_arrow_back_black_24dp);
        }
    }

    if (navigateBack.getDrawable() != drawable) {
        navigateBack.setImageDrawable(drawable);
    }

    if (mSearchResultsCursor != null && !mSearchResultsCursor.isEmpty()) {
        resetCardViewBackground(mSearchResultsCursor.getAll(), List.class);
        mSearchResultsCursor = null;
    }
}
 
開發者ID:Applications-Development,項目名稱:SimpleRssReader,代碼行數:33,代碼來源:MainActivity.java


注:本文中的android.widget.ImageButton.getDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。