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


Java Button.setCompoundDrawablesWithIntrinsicBounds方法代碼示例

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


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

示例1: setButton

import android.widget.Button; //導入方法依賴的package包/類
private void setButton(Button button, Message message, int index) {
    List<Action> actions = message.getActions();
    if (index >= actions.size()) {
        button.setVisibility(View.GONE);
        return;
    }
    Action action = (Action) actions.get(index);
    button.setOnClickListener(null);
    button.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
    button.setVisibility(View.VISIBLE);
    Drawable icon = getActionIcon(message.getAppId(), action.icon);
    icon.setColorFilter(new LightingColorFilter(ViewCompat.MEASURED_STATE_MASK, 6914181));
    button.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
    button.setText(action.title);
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:17,代碼來源:OverlayNotificationBarView.java

示例2: collapse

import android.widget.Button; //導入方法依賴的package包/類
/**
 * change to collapse image of button and display meal information
 *
 * @param when Integer constant of meal time to collapse
 */
private void collapse(int when) {
    TextView textView = null;
    Button button = null;
    String mealMenu = null;

    switch (when) {
        case BREAKFAST:
            textView = mBreakfastTV;
            button = mBreakfastExpandBtn;
            if (mSelectedDayMeal != null) mealMenu = mSelectedDayMeal.getBreakfast();
            break;
        case LUNCH:
            textView = mLunchTV;
            button = mLunchExpandBtn;
            if (mSelectedDayMeal != null) mealMenu = mSelectedDayMeal.getLunch();
            break;
        case DINNER:
            textView = mDinnerTV;
            button = mDinnerExpandBtn;
            if (mSelectedDayMeal != null) mealMenu = mSelectedDayMeal.getDinner();
            break;
        default:
            break;
    }

    textView.setText(mealMenu);
    button.setText(R.string.meal_allergy);

    Drawable moreDrawable =
            ContextCompat.getDrawable(getContext(), R.drawable.ic_expand_more_white_18dp);
    button.setCompoundDrawablesWithIntrinsicBounds(null, null, moreDrawable, null);

    button.setSelected(false);
}
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:40,代碼來源:MealFragment.java

示例3: expand

import android.widget.Button; //導入方法依賴的package包/類
/**
 * change to expand image of button and display allergy information
 *
 * @param when Integer constant of meal time to expand
 */
private void expand(int when) {
    TextView textView = null;
    Button button = null;
    String mealAllergy = null;

    switch (when) {
        case BREAKFAST:
            textView = mBreakfastTV;
            button = mBreakfastExpandBtn;
            if (mSelectedDayMeal != null) mealAllergy = mSelectedDayMeal.getBreakfastAllergy();
            break;
        case LUNCH:
            textView = mLunchTV;
            button = mLunchExpandBtn;
            if (mSelectedDayMeal != null) mealAllergy = mSelectedDayMeal.getLunchAllergy();
            break;
        case DINNER:
            textView = mDinnerTV;
            button = mDinnerExpandBtn;
            if (mSelectedDayMeal != null) mealAllergy = mSelectedDayMeal.getDinnerAllergy();
            break;
        default:
            break;
    }

    textView.setText(mealAllergy);
    button.setText(R.string.meal_meal);

    Drawable lessDrawable =
            ContextCompat.getDrawable(getContext(), R.drawable.ic_expand_less_white_18dp);
    lessDrawable.setColorFilter(
            ContextCompat.getColor(getContext(), R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
    button.setCompoundDrawablesWithIntrinsicBounds(null, null, lessDrawable, null);

    button.setSelected(true);
}
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:42,代碼來源:MealFragment.java

示例4: setBtnIcons

import android.widget.Button; //導入方法依賴的package包/類
public void setBtnIcons(int nScreenSizeCategory, int nScreenOrientation)	{
   	Button btnPrevInputPad = (Button)findViewById(R.id.btnPrevInputPad);
   	Button btnNextInputPad = (Button)findViewById(R.id.btnNextInputPad);
	if (nScreenSizeCategory >= Configuration.SCREENLAYOUT_SIZE_LARGE + 1)	{	//	xlarge size
    	// Configuration.SCREENLAYOUT_SIZE_XLARGE is not supported until Android 9, this is to ensure
    	// compatibility with Android 7.
    	btnPrevInputPad.setCompoundDrawablesWithIntrinsicBounds(R.drawable.toleft_land_large, 0, 0, 0);
    	btnNextInputPad.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.toright_land_large, 0);
    } else	{	// normal size or undefined size
    	btnPrevInputPad.setCompoundDrawablesWithIntrinsicBounds(R.drawable.toleft_land, 0, 0, 0);
    	btnNextInputPad.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.toright_land, 0);
    }
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:14,代碼來源:ActivityCfgKeyPad.java

示例5: getView

import android.widget.Button; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Project project = mProjects.get(position);
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
        convertView = inflater.inflate(R.layout.project_items, null);
    }

    Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
    appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());

    ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
    appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());

    LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
    if(actionBarLayout != null) {
        if(project.actionBarExpanded) {
            actionBarLayout.setVisibility(View.VISIBLE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_down), null);
        } else {
            actionBarLayout.setVisibility(View.GONE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_left), null);
        }
    }

    appNameButton.setText(project.name);
    appNameButton.setTag(R.id.positionId, position);
    appNameButton.setTag(R.id.textEdit, appNameEdit);
    appNameButton.setOnClickListener(appNameClickListener);
    appNameButton.setOnLongClickListener(appNameLongClickListener);

    appNameEdit.setTag(R.id.positionId, position);
    appNameEdit.setTag(R.id.editbutton, appNameButton);
    appNameEdit.setOnEditorActionListener(editorOnActionListener);
    appNameEdit.setFilters(new InputFilter[]{renameFilter});

    if(project.inEditMode) {
        appNameEdit.setVisibility(View.VISIBLE);

        appNameEdit.setText(project.name);
        appNameEdit.setSelection(project.name.length());
        appNameEdit.requestFocus();
        appNameButton.setVisibility(View.INVISIBLE);

    } else {
        appNameEdit.setVisibility(View.INVISIBLE);
        appNameButton.setVisibility(View.VISIBLE);
        //dismissKeyBoard(appNameEdit, false);
    }

    //appNameEdit.setOnClickListener(appNameClickListener);

    TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
    flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
    LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
    sendBtnLayout.setTag(position);
    sendBtnLayout.setOnClickListener(sendBtnClickListener);

    ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
    deleteBtn.setTag(position);
    deleteBtn.setOnClickListener(deleteBtnClickListener);
    deleteBtn.setEnabled(true);


    Drawable myIcon;
    if(project.runStatus) {
        flashBtnText.setText("");
        myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
    } else {
        flashBtnText.setText(R.string.flash);
        myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
    }
    sendBtnLayout.setBackground(myIcon);

    sendBtnLayout.setClickable(true);
    return convertView;
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:81,代碼來源:ProjectAdapter.java


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