当前位置: 首页>>代码示例>>Java>>正文


Java ImageButton.setBackgroundResource方法代码示例

本文整理汇总了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);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:27,代码来源:DrawForExpandLayout.java

示例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);
}
 
开发者ID:googlesamples,项目名称:android-media-controller,代码行数:31,代码来源:MediaAppControllerActivity.java

示例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;
    }
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:29,代码来源:PopupActivity.java

示例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;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:12,代码来源:AyahToolBar.java

示例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();
        }
    });
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:29,代码来源:DailyActivity.java

示例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();
        }
    });
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:35,代码来源:RecyclerViewActivity.java

示例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();
        }
    });
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:29,代码来源:SubjectActivity.java

示例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);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:71,代码来源:EmojiPalettesView.java


注:本文中的android.widget.ImageButton.setBackgroundResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。