本文整理汇总了Java中android.widget.ImageButton.setBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setBackgroundResource方法的具体用法?Java ImageButton.setBackgroundResource怎么用?Java ImageButton.setBackgroundResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageButton
的用法示例。
在下文中一共展示了ImageButton.setBackgroundResource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.widget.ImageButton; //导入方法依赖的package包/类
/**
* <ImageButton
android:id="@+id/ancp_poi_list_drap_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/new_line_border"
android:src="@drawable/bnav_poi_list_drag"
android:paddingBottom="10dp"
android:paddingTop="10dp"
/>
*/
private void init(){
DisplayMetrics metrics=getContext().getResources().getDisplayMetrics();
density=metrics.density;
sHeight=metrics.heightPixels;
minHeight=dp2px(50);
Log.i(TAG,"sHeight="+sHeight+",minHeight="+50);
drawBar=new ImageButton(getContext());
LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
drawBar.setBackgroundResource(R.color.base_blue_translucent);
drawBar.setImageResource(R.drawable.bnav_poi_list_drag);
drawBar.setPadding(0, dp2px(10), 0, dp2px(10));
addView(drawBar, 0, layoutParams);
drawBar.setOnTouchListener(drawTouchListener);
}
示例2: showActions
import android.widget.ImageButton; //导入方法依赖的package包/类
/**
* This updates the buttons on the controller view to show actions that
* aren't included in the declared supported actions in red to more easily
* detect potential bugs.
*
* @param actions The mask of currently supported actions from {@see
* PlaybackStateCompat.getActions()}.
*/
private void showActions(@PlaybackStateCompat.Actions long actions) {
final int count = mActionViewIdMap.size();
for (int i = 0; i < count; ++i) {
final int viewId = mActionViewIdMap.keyAt(i);
final long action = mActionViewIdMap.valueAt(i);
final ImageButton button = mActionButtonMap.get(viewId);
if (actionSupported(actions, action)) {
button.setBackground(null);
} else {
button.setBackgroundResource(R.drawable.bg_unsuported_action);
}
}
final boolean shuffleEnabled =
mController.getShuffleMode() == PlaybackStateCompat.SHUFFLE_MODE_ALL ||
mController.getShuffleMode() == PlaybackStateCompat.SHUFFLE_MODE_GROUP;
final int shuffleTint = shuffleEnabled
? ContextCompat.getColor(this, R.color.colorPrimary)
: ContextCompat.getColor(this, R.color.colorInactive);
DrawableCompat.setTint(mShuffleToggle.getDrawable(), shuffleTint);
}
示例3: handleMessage
import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case PROCESS_DEFINITION_LIST:
showSearchButton();
List<Definition> definitionList = (List<Definition>) msg.obj;
processDefinitionList(definitionList);
break;
case ASYNC_SEARCH_FAILED:
showSearchButton();
Toast.makeText(PopupActivity.this, (String) msg.obj, Toast.LENGTH_LONG).show();
break;
case SET_ADDED:
progressDialog.hide();
ImageButton btn = (ImageButton) msg.obj;
btn.setBackgroundResource(R.drawable.ic_add_grey);
btn.setEnabled(false);
Toast.makeText(PopupActivity.this, R.string.term_added, Toast.LENGTH_SHORT).show();
break;
case SET_ADD_FAILED:
progressDialog.hide();
String message = (String) msg.obj;
Toast.makeText(PopupActivity.this, message, Toast.LENGTH_SHORT).show();
break;
default:
break;
}
}
示例4: getMenuItemView
import android.widget.ImageButton; //导入方法依赖的package包/类
private View getMenuItemView(MenuItem item) {
final ImageButton button = new ImageButton(context);
button.setImageDrawable(item.getIcon());
button.setBackgroundResource(R.drawable.toolbar_button);
button.setId(item.getItemId());
button.setLayoutParams(new LayoutParams(itemWidth,
ViewGroup.LayoutParams.MATCH_PARENT));
button.setOnClickListener(this);
button.setOnLongClickListener(this);
return button;
}
示例5: initToolbar
import android.widget.ImageButton; //导入方法依赖的package包/类
private void initToolbar() {
Button mToolbarButton = (Button) findViewById(R.id.tool_bar_button);
mToolbarButton.setVisibility(View.GONE);
ImageButton mSearchButton = (ImageButton) findViewById(R.id.search_button);
mSearchButton.setVisibility(View.GONE);
TextView mTitleText = (TextView) findViewById(R.id.title_text);
mTitleText.setText("每日编辑精选");
mTitleText.setTextSize(16);
mTitleText.setTypeface(Typeface.createFromAsset(getAssets(), getString(R.string.DB1FontPath)));
mToolbar = (Toolbar) findViewById(R.id.tool_bar);
ImageButton mExitButton = new ImageButton(this);
mExitButton.setBackgroundResource(R.drawable.ic_action_back_black);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.tool_bar_layout);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100, 120);
params.gravity = Gravity.CENTER_VERTICAL;
params.leftMargin = 10;
frameLayout.addView(mExitButton, params);
setSupportActionBar(mToolbar);
mExitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
示例6: initToolbar
import android.widget.ImageButton; //导入方法依赖的package包/类
private void initToolbar(int flag) {
Button mToolbarButton = (Button) findViewById(R.id.tool_bar_button);
mToolbarButton.setVisibility(View.GONE);
ImageButton mSearchButton = (ImageButton) findViewById(R.id.search_button);
mSearchButton.setVisibility(View.GONE);
mTitleText = (TextView) findViewById(R.id.title_text);
if (flag == FLAG_ALL_CATEGORY) {
mTitleText.setText(TITLE_CATEGORY);
} else if (flag == FLAG_HOT_SUBJECT) {
mTitleText.setText(TITLE_SUBJECT);
} else if (flag == FLAG_ALL_AUTHOR) {
mTitleText.setText(TITLE_AUTHOR);
}
mTitleText.setTextSize(16);
mTitleText.setTypeface(Typeface.createFromAsset(getAssets(), getString(R.string.DB1FontPath)));
mToolbar = (Toolbar) findViewById(R.id.tool_bar);
ImageButton mExitButton = new ImageButton(this);
mExitButton.setBackgroundResource(R.drawable.ic_action_back_black);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.tool_bar_layout);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100, 120);
params.gravity = Gravity.CENTER_VERTICAL;
params.leftMargin = 10;
frameLayout.addView(mExitButton, params);
setSupportActionBar(mToolbar);
mExitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
示例7: initToolbar
import android.widget.ImageButton; //导入方法依赖的package包/类
private void initToolbar() {
Button mToolbarButton = (Button) findViewById(R.id.tool_bar_button);
mToolbarButton.setVisibility(View.GONE);
ImageButton mSearchButton = (ImageButton) findViewById(R.id.search_button);
mSearchButton.setVisibility(View.GONE);
mTitleText = (TextView) findViewById(R.id.title_text);
mTitleText.setText("");
mTitleText.setTextSize(16);
mTitleText.setTypeface(Typeface.createFromAsset(getAssets(), getString(R.string.DB1FontPath)));
mToolbar = (Toolbar) findViewById(R.id.tool_bar);
mExitButton = new ImageButton(this);
mExitButton.setBackgroundResource(R.drawable.ic_action_back_black);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.tool_bar_layout);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100, 120);
params.gravity = Gravity.CENTER_VERTICAL;
params.leftMargin = 10;
frameLayout.addView(mExitButton, params);
setSupportActionBar(mToolbar);
mExitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
示例8: 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);
}