本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}