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


Java ImageButton.setImageDrawable方法代码示例

本文整理汇总了Java中android.widget.ImageButton.setImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setImageDrawable方法的具体用法?Java ImageButton.setImageDrawable怎么用?Java ImageButton.setImageDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageButton的用法示例。


在下文中一共展示了ImageButton.setImageDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setNumberKey

import android.widget.ImageButton; //导入方法依赖的package包/类
private void setNumberKey(ImageButton buttonView, int key) {
    Drawable tempDrawable = null;
    if (null != mNumForeSelectorArray[key]) {
        tempDrawable = mNumForeSelectorArray[key].getConstantState()
                .newDrawable();
        buttonView.setImageDrawable(tempDrawable);
    }
    if (null != mNumBgSelectorArray
            && null != mNumBgSelectorArray[key]) {
        tempDrawable = mNumBgSelectorArray[key].getConstantState()
                .newDrawable();
        buttonView.setBackgroundDrawable(tempDrawable);
    } else if (null != mNumBgDrawSelector) {
        tempDrawable = mNumBgDrawSelector.getConstantState()
                .newDrawable();
        buttonView.setBackgroundDrawable(tempDrawable);
    }
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:19,代码来源:SafetyKeyboard.java

示例2: applyTheme

import android.widget.ImageButton; //导入方法依赖的package包/类
public void applyTheme(Theme t) {
    
	Log.d(THIS_FILE, "Theming in progress");
	for(int buttonId : DIGITS_BTNS.keySet()) {
		
		ImageButton b = (ImageButton) findViewById(buttonId);
		// We need to use state list as reused
		t.applyBackgroundStateListDrawable(b, "btn_dial");
		
		// Src of button
		Drawable src = t.getDrawableResource("dial_num_"+DIGITS_NAMES.get(buttonId));
		if(src != null) {
			b.setImageDrawable(src);
		}
		
		// Padding of button
		t.applyLayoutMargin(b, "dialpad_btn_margin");
	}
	
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:21,代码来源:Dialpad.java

示例3: updateQuickLaunchButtons

import android.widget.ImageButton; //导入方法依赖的package包/类
void updateQuickLaunchButtons() {
    final AppManager appManager = (AppManager) GuiceModule.get().getInstance(AppManager.class);
    List<App> quickLaunchApps = appManager.getQuickLaunchApps();
    for (int i = 0; i < this.buttons.size(); i++) {
        ImageButton button = (ImageButton) this.buttons.get(i);
        if (i < quickLaunchApps.size()) {
            final App app = (App) quickLaunchApps.get(i);
            button.setImageDrawable(app.getAppIcon());
            button.setOnClickListener(new OnClickListener() {
                public void onClick(View view) {
                    ((InboxViewManager) GuiceModule.get().getInstance(InboxViewManager.class)).closeDrawer();
                    appManager.launchAppWithBackButton(app, AppLaunchMethod.Quicklaunch);
                }
            });
        } else {
            button.setImageDrawable(null);
            button.setOnClickListener(null);
        }
    }
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:21,代码来源:QuickLaunchView.java

示例4: setOkButton

import android.widget.ImageButton; //导入方法依赖的package包/类
public static void setOkButton(final BaseActivity activity, int resource) {
    TextView tvOk = (TextView) activity.findViewById(R.id.tv_right);
    ImageButton btnOk = (ImageButton) activity.findViewById(R.id.btn_right);
    if (btnOk != null) {
        tvOk.setVisibility(View.GONE);
        if (resource != 0) {
            btnOk.setImageDrawable(activity.getResources().getDrawable(resource));
        }
        btnOk.setVisibility(View.VISIBLE);
        btnOk.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                activity.onOkButtonClick();
            }
        });
    }
}
 
开发者ID:DoloresTeam,项目名称:dolores-android,代码行数:19,代码来源:TitleUtils.java

示例5: onBindView

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    LinearLayout widgetFrameView = ((LinearLayout) view.findViewById(android.R.id.widget_frame));
    mBtnAppIcon = new ImageButton(mContext);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mAppIconPreviewSizePx, mAppIconPreviewSizePx);
    lp.gravity = Gravity.CENTER;
    mBtnAppIcon.setLayoutParams(lp);
    mBtnAppIcon.setScaleType(ScaleType.CENTER_CROP);
    mBtnAppIcon.setImageDrawable(mAppInfo.icon);
    mBtnAppIcon.setFocusable(false);
    if (mIconPickerEnabled) {
        mBtnAppIcon.setOnClickListener(this);
        mBtnAppIcon.setOnLongClickListener(this);
    } else {
        mBtnAppIcon.setEnabled(false);
    }
    widgetFrameView.addView(mBtnAppIcon);
    widgetFrameView.setVisibility(View.VISIBLE);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:22,代码来源:AppPickerPreference.java

示例6: setDoneKey

import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDoneKey(ImageButton buttonView) {
    if (null != mDoneForeSelector) {
        buttonView.setImageDrawable(mDoneForeSelector);

    }
    if (null != mDoneBgSelector) {
        buttonView.setBackgroundDrawable(mDoneBgSelector);
    }
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:10,代码来源:SafetyKeyboard.java

示例7: setDelKey

import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDelKey(ImageButton buttonView) {
    if (null != mDelForeSelector) {
        buttonView.setImageDrawable(mDelForeSelector);
    }
    if (null != mDelBgSelector) {
        buttonView.setBackgroundDrawable(mDelBgSelector);
    }
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:9,代码来源:SafetyKeyboard.java

示例8: setUpButtons

import android.widget.ImageButton; //导入方法依赖的package包/类
/**
 * Sets up the overlay buttons
 */
private void setUpButtons() {
    // Set up copy buttons
    ImageButton firstname = view.findViewById(R.id.copy_firstname);
    ImageButton middlename = view.findViewById(R.id.copy_middlename);
    ImageButton lastname = view.findViewById(R.id.copy_lastname);
    ImageButton username = view.findViewById(R.id.copy_username);
    ImageButton email = view.findViewById(R.id.copy_email);
    ImageButton password = view.findViewById(R.id.copy_password);
    ImageButton date = view.findViewById(R.id.copy_date);

    // Set listeners for copy buttons
    firstname.setOnClickListener(this);
    middlename.setOnClickListener(this);
    lastname.setOnClickListener(this);
    username.setOnClickListener(this);
    email.setOnClickListener(this);
    password.setOnClickListener(this);
    date.setOnClickListener(this);

    // Set listeners for general clicks, dismiss, save, background and card click
    view.findViewById(R.id.button_dismiss).setOnClickListener(this);
    view.findViewById(R.id.button_save).setOnClickListener(this);
    view.findViewById(R.id.background).setOnClickListener(this);
    view.findViewById(R.id.card_content).setOnClickListener(this);


    // Create copy icon drawable
    Drawable copyIcon = getDrawable(R.drawable.icon_copy);
    // Set each copy button to use the copy icon
    firstname.setImageDrawable(copyIcon);
    middlename.setImageDrawable(copyIcon);
    lastname.setImageDrawable(copyIcon);
    username.setImageDrawable(copyIcon);
    email.setImageDrawable(copyIcon);
    password.setImageDrawable(copyIcon);
    date.setImageDrawable(copyIcon);
}
 
开发者ID:jthomperoo,项目名称:Forge,代码行数:41,代码来源:OverlayService.java

示例9: 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

示例10: setBookmarked

import android.widget.ImageButton; //导入方法依赖的package包/类
public void setBookmarked(boolean bookmarked) {
  MenuItem bookmarkItem = menu.findItem(R.id.cab_bookmark_ayah);
  bookmarkItem.setIcon(bookmarked ? R.drawable.ic_favorite : R.drawable.ic_not_favorite);
  ImageButton bookmarkButton = (ImageButton) findViewById(R.id.cab_bookmark_ayah);
  if (bookmarkButton != null) {
    bookmarkButton.setImageDrawable(bookmarkItem.getIcon());
  }
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:9,代码来源:AyahToolBar.java

示例11: instantiateItem

import android.widget.ImageButton; //导入方法依赖的package包/类
public Object instantiateItem(ViewGroup container, int position) {
    LayoutInflater inflater = (LayoutInflater) QuickLaunchView.this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout pageView = (LinearLayout) inflater.inflate(R.layout.shade_quick_launch_page, null);
    for (int i = position * 5; i < (position * 5) + 5; i++) {
        ImageButton button = (ImageButton) inflater.inflate(R.layout.quicklaunch_button, null);
        button.setScaleType(ScaleType.FIT_CENTER);
        if (i < this.quickLaunchApps.size()) {
            final App app = (App) this.quickLaunchApps.get(i);
            button.setImageDrawable(app.getAppIcon());
            button.setOnClickListener(new OnClickListener() {
                public void onClick(View view) {
                    ((InboxViewManager) GuiceModule.get().getInstance(InboxViewManager.class)).closeDrawer();
                    LockScreenManager lockScreenManager = (LockScreenManager) GuiceModule.get().getInstance(LockScreenManager.class);
                    if (lockScreenManager.isPhoneLocked()) {
                        lockScreenManager.unlockAndLaunchApp(app);
                    } else {
                        QuickLaunchView.this.appManager.launchAppWithBackButton(app, AppLaunchMethod.Quicklaunch);
                    }
                }
            });
        } else {
            button.setBackground(null);
            button.setOnClickListener(null);
        }
        pageView.addView(button, new LayoutParams(-1, -1, 0.5f));
    }
    container.addView(pageView);
    return pageView;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:30,代码来源:QuickLaunchView.java

示例12: setImageButtonEnabled

import android.widget.ImageButton; //导入方法依赖的package包/类
public static void setImageButtonEnabled(Context ctxt, boolean enabled, ImageButton item,
                                         int iconResId) {
    item.setEnabled(enabled);
    Drawable originalIcon = ctxt.getResources().getDrawable(iconResId);
    Drawable icon = enabled ? originalIcon : convertDrawableToGrayScale(originalIcon);
    item.setImageDrawable(icon);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:8,代码来源:Util.java

示例13: playPauseBtnClicked

import android.widget.ImageButton; //导入方法依赖的package包/类
public void playPauseBtnClicked(ImageButton btnPlayPause) {
    if (mediaPlayer != null) {
        if (mediaPlayer.isPlaying()) {
            mediaPlayer.pause();
            btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
                    this,
                    R.drawable.ic_play_red_48dp));
        } else {
            mediaPlayer.start();
            btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
                    this,
                    R.drawable.ic_pause_red_48dp));
        }
    }
}
 
开发者ID:GautamChibde,项目名称:android-audio-visualizer,代码行数:16,代码来源:BaseActivity.java

示例14: changeIconColor

import android.widget.ImageButton; //导入方法依赖的package包/类
private void changeIconColor(ImageButton imagebutton, String category, boolean isSever)
{
    if (imagebutton==null)
        return;

    String ressourceName=category;

    if (isSever)
        ressourceName+="_red";
    else
        ressourceName+="_green";

    imagebutton.setImageDrawable(getDrawable(ressourceName));

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:16,代码来源:FragmentHome.java

示例15: onSearchViewQueryChange

import android.widget.ImageButton; //导入方法依赖的package包/类
private void onSearchViewQueryChange(final String query, final ImageButton navigateBack,
                               final TextView results) {
    final boolean isDarkThemeSelected = ThemeUtils.isDarkThemeSelected(this);
    final Drawable drawable;

    if (!TextUtils.isEmpty(query)) {
        if (isDarkThemeSelected) {
            drawable = getDrawable(R.drawable.ic_clear_white_24dp);
        } else {
            drawable = getDrawable(R.drawable.ic_clear_black_24dp);
        }
    } else {
        if (results.getVisibility() != View.INVISIBLE) {
            results.setVisibility(View.INVISIBLE);
        }

        if (isDarkThemeSelected) {
            drawable = getDrawable(R.drawable.ic_arrow_back_white_24dp);
        } else {
            drawable = getDrawable(R.drawable.ic_arrow_back_black_24dp);
        }
    }

    if (navigateBack.getDrawable() != drawable) {
        navigateBack.setImageDrawable(drawable);
    }

    if (mSearchResultsCursor != null && !mSearchResultsCursor.isEmpty()) {
        resetCardViewBackground(mSearchResultsCursor.getAll(), List.class);
        mSearchResultsCursor = null;
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:33,代码来源:MainActivity.java


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