本文整理汇总了Java中android.widget.ImageButton.setTag方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setTag方法的具体用法?Java ImageButton.setTag怎么用?Java ImageButton.setTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageButton
的用法示例。
在下文中一共展示了ImageButton.setTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRowToNumbersList
import android.widget.ImageButton; //导入方法依赖的package包/类
private boolean addRowToNumbersList(@NonNull String number, int type) {
// create and add the new row
LayoutInflater inflater = getActivity().getLayoutInflater();
View row = inflater.inflate(R.layout.row_contact_number, numbersViewList, false);
numbersViewList.addView(row);
// init row with number data
setNumberType(row, type);
setNumber(row, number);
// init 'row remove' button
ImageButton buttonRemove = (ImageButton) row.findViewById(R.id.button_remove);
buttonRemove.setTag(row);
buttonRemove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
numbersViewList.removeView((View) v.getTag());
}
});
// scroll list down
moveScroll();
return true;
}
示例2: animateCloseButtonVisibility
import android.widget.ImageButton; //导入方法依赖的package包/类
/**
* Animates the visibility of a tab's close button.
*
* @param viewHolder
* The view holder, which holds a reference to the close button, whose visibility should
* be animated, as an instance of the class {@link AbstractTabViewHolder}. The view
* holder may not be null
* @param show
* True, if the close button should be shown, false otherwise
*/
private void animateCloseButtonVisibility(@NonNull final AbstractTabViewHolder viewHolder,
final boolean show) {
ImageButton closeButton = viewHolder.closeButton;
Boolean visible = (Boolean) closeButton.getTag(R.id.tag_visibility);
if (visible == null || visible != show) {
closeButton.setTag(R.id.tag_visibility, show);
if (closeButton.getAnimation() != null) {
closeButton.getAnimation().cancel();
}
ViewPropertyAnimator animation = closeButton.animate();
animation.setListener(createCloseButtonVisibilityAnimationListener(viewHolder, show));
animation.alpha(show ? 1 : 0);
animation.setStartDelay(0);
animation.setDuration(closeButtonVisibilityAnimationDuration);
animation.start();
}
}
示例3: onCreate
import android.widget.ImageButton; //导入方法依赖的package包/类
/**
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
estado = Estado.NAO_VIRADA;
grid = (GridLayout) findViewById(R.id.grid);
grid.setColumnCount(4);
final int NUMBER_OF_CARDS = this.resources.length * 2;
cards = new ArrayList<>(NUMBER_OF_CARDS);
for (int i = 0; i < NUMBER_OF_CARDS; i++) {
ImageButton btn = new ImageButton(this);
btn.setImageResource(R.mipmap.ic_costas);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(150, 150);
btn.setLayoutParams(layoutParams);
btn.setOnClickListener(this);
btn.setTag(new CardInfo(resources[i % 8]));
cards.add(btn);
}
Collections.shuffle(cards);
for(ImageButton button : this.cards ){
grid.addView(button);
}
}
示例4: RightLeftButtonsBar
import android.widget.ImageButton; //导入方法依赖的package包/类
public RightLeftButtonsBar(Context context, BrailleLayout brailleLayout) {
super(context);
try {
this.context = context;
this.surfaceContainer = brailleLayout.getBrailleLayoutContainer(context);
this.brailleLayout = brailleLayout;
this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
MyAccessibilityEventHandler myAccessibilityEventHandler = new MyAccessibilityEventHandler();
setOnTouchListener(this);
//views declarations
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.ops_buttons_right_left, this, true);
makeKeyboardFullWidth = (ImageButton) view.findViewById(R.id.makeKeyboardFullWidth);
moveKeyboardRightLeft = (ImageButton) view.findViewById(R.id.moveKeyboardRightLeft);
if (Common.startKeyboardContainerFromRight) {
moveKeyboardRightLeft.setTag("right");
moveKeyboardRightLeft.setImageResource(R.mipmap.ic_keyboard_arrow_left_white_48dp);
} else {
moveKeyboardRightLeft.setTag("left");
moveKeyboardRightLeft.setImageResource(R.mipmap.ic_keyboard_arrow_right_white_48dp);
}
//Listeners
makeKeyboardFullWidth.setAccessibilityDelegate(myAccessibilityEventHandler);
makeKeyboardFullWidth.setOnTouchListener(this);
moveKeyboardRightLeft.setAccessibilityDelegate(myAccessibilityEventHandler);
moveKeyboardRightLeft.setOnTouchListener(this);
//To get the width and height after before the view got rendered
ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
makeKeyboardFullWidthRect.set(makeKeyboardFullWidth.getLeft(), makeKeyboardFullWidth.getTop(),
makeKeyboardFullWidth.getRight(), makeKeyboardFullWidth.getTop() + makeKeyboardFullWidth.getHeight());
moveKeyboardRightLeftRect.set(moveKeyboardRightLeft.getLeft(), moveKeyboardRightLeft.getTop(),
moveKeyboardRightLeft.getRight(), moveKeyboardRightLeft.getTop() + moveKeyboardRightLeft.getHeight());
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: getView
import android.widget.ImageButton; //导入方法依赖的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;
}
示例6: onFinishInflate
import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost);
mTabHost.setup();
for (final EmojiCategory.CategoryProperties properties
: mEmojiCategory.getShownCategories()) {
addTab(mTabHost, properties.mCategoryId);
}
mTabHost.setOnTabChangedListener(this);
final TabWidget tabWidget = mTabHost.getTabWidget();
tabWidget.setStripEnabled(mCategoryIndicatorEnabled);
if (mCategoryIndicatorEnabled) {
// On TabWidget's strip, what looks like an indicator is actually a background.
// And what looks like a background are actually left and right drawables.
tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId);
tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId);
tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId);
}
mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this);
mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager);
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
mEmojiPager.setOnPageChangeListener(this);
mEmojiPager.setOffscreenPageLimit(0);
mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE);
mEmojiLayoutParams.setPagerProperties(mEmojiPager);
mEmojiCategoryPageIndicatorView =
(EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view);
mEmojiCategoryPageIndicatorView.setColors(
mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground);
mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);
final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar);
mEmojiLayoutParams.setActionBarProperties(actionBar);
// deleteKey depends only on OnTouchListener.
mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete);
mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
mDeleteKey.setTag(Constants.CODE_DELETE);
mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
// {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on
// {@link View.OnClickListener} as well as {@link View.OnTouchListener}.
// {@link View.OnTouchListener} is used as the trigger of key-press, while
// {@link View.OnClickListener} is used as the trigger of key-release which does not occur
// if the event is canceled by moving off the finger from the view.
// The text on alphabet keys are set at
// {@link #startEmojiPalettes(String,int,float,Typeface)}.
mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left);
mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyLeft.setOnTouchListener(this);
mAlphabetKeyLeft.setOnClickListener(this);
mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right);
mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyRight.setOnTouchListener(this);
mAlphabetKeyRight.setOnClickListener(this);
mSpacebar = findViewById(R.id.emoji_keyboard_space);
mSpacebar.setBackgroundResource(mSpacebarBackgroundId);
mSpacebar.setTag(Constants.CODE_SPACE);
mSpacebar.setOnTouchListener(this);
mSpacebar.setOnClickListener(this);
mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
}