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


Java ImageButton.setImageResource方法代码示例

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


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

示例1: updatePlayPauseButtonImageResource

import android.widget.ImageButton; //导入方法依赖的package包/类
private void updatePlayPauseButtonImageResource(ImageButton button) {
    CastSession castSession = CastContext.getSharedInstance(mAppContext)
            .getSessionManager().getCurrentCastSession();
    RemoteMediaClient remoteMediaClient =
            (castSession == null) ? null : castSession.getRemoteMediaClient();
    if (remoteMediaClient == null) {
        button.setVisibility(View.GONE);
        return;
    }
    int status = remoteMediaClient.getPlayerState();
    switch (status) {
        case MediaStatus.PLAYER_STATE_PLAYING:
            button.setImageResource(PAUSE_RESOURCE);
            break;
        case MediaStatus.PLAYER_STATE_PAUSED:
            button.setImageResource(PLAY_RESOURCE);
            break;
        default:
            button.setVisibility(View.GONE);
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:22,代码来源:QueueListAdapter.java

示例2: onBindViewHolder

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if(styleManager.getItemViewType(position) == BottomStyleManager.ITEM_EMOJ) {
        ImageButton image = (ImageButton) holder.itemView;
        EmojiStyleWrapper wrapper = mEmojiStyleWrapperManager.getStyleWrapperByStyleItem(position);
        int resourceId = wrapper.getStyleIcon();
        if (resourceId > 0) {
            image.setImageResource(resourceId);
        }
        if (wrapper.isSelected()) {
            image.setSelected(true);
        } else {
            image.setSelected(false);
        }
        holder.itemView.setOnClickListener(new ItemClick(holder, position));
    }else {
        View.OnClickListener clickListener = (View.OnClickListener) holder.itemView.getTag(R.id.bottom_item_click);
        if(clickListener != null) {
            holder.itemView.setOnClickListener(clickListener);
        }
    }
}
 
开发者ID:nickyangjun,项目名称:EasyEmoji,代码行数:23,代码来源:EmojiStylesFragment.java

示例3: internalOnCreate

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void internalOnCreate(Bundle savedInstanceState) {
    totalText = (TextView)findViewById(R.id.total);
    filterText = (TextView)findViewById(R.id.period);
    ImageButton bFilter = (ImageButton) findViewById(R.id.bFilter);
    bFilter.setImageResource(R.drawable.ic_menu_filter_on);
    bFilter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showFilter();
        }
    });

    loadFilter();
    setupFilter();
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:17,代码来源:PlannerActivity.java

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

示例5: addTab

import android.widget.ImageButton; //导入方法依赖的package包/类
public void addTab(@DrawableRes int iconId, @IdRes int id, OnClickListener onClickListener) {
        ImageButton view = (ImageButton) mInflater.inflate(R.layout.item_tab_icon, mLayout, false);
        view.setImageResource(iconId);
        view.setId(id);
        view.setOnClickListener(onClickListener);
        mLayout.addView(view, mLayout.getChildCount());
        //滑到最右边
//        this.postDelayed(() -> this.smoothScrollBy(1000, 0), 5);
        this.postDelayed(new Runnable() {
            @Override
            public void run() {
                smoothScrollBy(1000, 0);
            }
        }, 5);
    }
 
开发者ID:weimin96,项目名称:shareNote,代码行数:16,代码来源:TabIconView.java

示例6: updatePausePlay

import android.widget.ImageButton; //导入方法依赖的package包/类
protected void updatePausePlay(boolean isPlaying, ImageButton pauseButton)
{
    if (isPlaying)
    {
        pauseButton.setImageResource(R.mipmap.vvc_ic_media_pause);
    }
    else
    {
        pauseButton.setImageResource(R.mipmap.vvc_ic_media_play);
    }
}
 
开发者ID:Dreamxiaoxuan,项目名称:AndroidTvDemo,代码行数:12,代码来源:CustomMediaController.java

示例7: togglePlayPause

import android.widget.ImageButton; //导入方法依赖的package包/类
public void togglePlayPause(View v) {
    if(isDrawerVisible(findViewById(android.R.id.content))) return;
    ImageButton img = (ImageButton)v.findViewById(R.id.play_pause);
    if(!PlayerState.CURRENTLY_PLAYING){
        img.setImageResource(R.drawable.pause_small);
        playPlayerService();
        sendBluetoothMeta = true;
    } else {
        img.setImageResource(R.drawable.arrow_small);
        pausePlayerService();
        sendBluetoothMeta = false;
    }
}
 
开发者ID:R-a-dio,项目名称:R-a-dio-Amazing-Android-App,代码行数:14,代码来源:ActivityMain.java

示例8: addIconTab

import android.widget.ImageButton; //导入方法依赖的package包/类
private void addIconTab(int position, int resId) {
    ImageButton tab = new ImageButton(getContext());
    tab.setImageResource(resId);
    addTab(position, tab);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:PagerSlidingTabStrip.java

示例9: redKeyDown

import android.widget.ImageButton; //导入方法依赖的package包/类
private void redKeyDown() {
    ImageButton redKey;
    switch (languageIndex) {
        case CHINESE_LANGUAGE:
        case ENGLISH_LANGUAGE:
        case RUSSIAN_LANGUAGE:
            if (keyboardType == ALPHABET_KEYBOARD) {
                redKey = findViewById(R.id.redButton);
                if (bCapSwitch) {

                    redKey.setImageResource(R.mipmap.capsoff);
                    bCapSwitch = !bCapSwitch;
                } else {
                    redKey.setImageResource(R.mipmap.capson);
                    bCapSwitch = !bCapSwitch;
                }
            } else if (keyboardType == DIGITAL_KEYBOARD) {
                keyboardType = SYMBOL_KEYBOARD;
            } else if (keyboardType == SYMBOL_KEYBOARD) {
                keyboardType = DIGITAL_KEYBOARD;
            }
            break;
        case ARABIC_LANGUAGE:
        case FARSI_LANGUAGE:
            if (keyboardType == ALPHABET_KEYBOARD) {
                return;

            } else if (keyboardType == DIGITAL_KEYBOARD) {
                keyboardType = SYMBOL_KEYBOARD;
            } else if (keyboardType == SYMBOL_KEYBOARD) {
                keyboardType = DIGITAL_KEYBOARD;
            }

            break;
        case TURKEY_LANGUAGE:
        case GERMAN_LANGUAGE:
        case FRANCE_LANGUAGE:
        case SPANISH_LANGUAGE:
        case ITALY_LANGUAGE:
            if (keyboardType == ALPHABET_KEYBOARD) {
                redKey = findViewById(R.id.redButton);
                if (bCapSwitch) {

                    redKey.setImageResource(R.mipmap.capsoff);
                    bCapSwitch = !bCapSwitch;
                } else {
                    redKey.setImageResource(R.mipmap.capson);
                    bCapSwitch = !bCapSwitch;
                }
            } else if (keyboardType == DIGITAL_KEYBOARD) {
                keyboardType = SYMBOL_KEYBOARD;
            } else {
                if (keyboardType == SYMBOL_KEYBOARD) {
                    redKey = findViewById(R.id.redButton);
                    if (bCapSwitch) {

                        redKey.setImageResource(R.mipmap.capsoff);
                        bCapSwitch = !bCapSwitch;
                    } else {
                        redKey.setImageResource(R.mipmap.capson);
                        bCapSwitch = !bCapSwitch;
                    }
                }
            }
            break;
        default:
            break;
    }
    vFocusView = RED_KEY_FOCUS;
    text = inputText.getText().toString();
    initKeyboard();
}
 
开发者ID:coderJohnZhang,项目名称:TvSoftKeyboard,代码行数:73,代码来源:GlobalSoftKeyboard.java

示例10: onClick

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    if (getMusicXService() == null) {
        return;
    }
    switch (view.getId()) {

        case R.id.play_pause_toggle:
            getMusicXService().toggle();
            break;
        case R.id.action_favorite:
            ImageButton button = (ImageButton) view;
            if (favhelper.isFavorite(getMusicXService().getsongId())) {
                favhelper.removeFromFavorites(getMusicXService().getsongId());
                button.setImageResource(R.drawable.ic_action_favorite_outline);
                getMusicXService().updateService(Constants.META_CHANGED);
            } else {
                favhelper.addFavorite(getMusicXService().getsongId());
                button.setImageResource(R.drawable.ic_action_favorite);
                like(view);
                getMusicXService().updateService(Constants.META_CHANGED);
            }
            break;
        case R.id.shuffle_song:
            boolean shuffle = getMusicXService().isShuffleEnabled();
            getMusicXService().setShuffleEnabled(!shuffle);
            updateShuffleButton();
            break;
        case R.id.repeat_song:
            int mode = getMusicXService().getNextrepeatMode();
            getMusicXService().setRepeatMode(mode);
            updateRepeatButton();
            break;
        case R.id.menu_button:
            queue = new Queue() {
                @Override
                public void clearStuff() {
                    if (queueAdapter.getSnapshot().size() > 0) {
                        CommonDatabase commonDatabase = new CommonDatabase(getContext(), Queue_TableName, true);
                        ;
                        queueAdapter.clear();
                        queueAdapter.notifyDataSetChanged();
                        getMusicXService().clearQueue();
                        try {
                            commonDatabase.removeAll();
                        } finally {
                            commonDatabase.close();
                        }
                        Toast.makeText(getContext(), "Cleared Queue", Toast.LENGTH_SHORT).show();
                    }
                }
            };
            playingMenu(queue, view, true);
            break;
        case R.id.next:
            getMusicXService().playnext(true);
            break;
        case R.id.prev:
            getMusicXService().playprev(true);
            break;
        case R.id.show_queue:
            if (flag) {
                Helper.getCircularShowAnimtion(queueViews).start();
                queueViews.setVisibility(View.VISIBLE);
                if (vizualview != null) {
                    vizualview.setVisibility(View.GONE);
                }
                flag = false;
            } else {
                Helper.getCircularHideAnimtion(queueViews).start();
                queueViews.setVisibility(View.GONE);
                if (vizualview != null) {
                    vizualview.setVisibility(View.VISIBLE);
                }
                flag = true;
            }
            break;

    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:81,代码来源:Playing4Fragment.java

示例11: initMainLeftViews

import android.widget.ImageButton; //导入方法依赖的package包/类
/**
 * 初始化主视图左边部分
 *
 * @param context
 */
private void initMainLeftViews(Context context) {
    LayoutParams leftInnerParams = new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    leftInnerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    leftInnerParams.addRule(RelativeLayout.CENTER_VERTICAL);

    if (leftType == TYPE_LEFT_TEXTVIEW) {
        // 初始化左边TextView
        tvLeft = new TextView(context);
        tvLeft.setId(ViewFinder.generateViewId());
        tvLeft.setText(leftText);
        tvLeft.setTextColor(leftTextColor);
        tvLeft.setTextSize(TypedValue.COMPLEX_UNIT_PX, leftTextSize);
        tvLeft.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        tvLeft.setSingleLine(true);
        tvLeft.setOnClickListener(this);
        // 设置DrawableLeft及DrawablePadding
        if (leftDrawable != 0) {
            tvLeft.setCompoundDrawablePadding((int) leftDrawablePadding);
            if (SysUtils.hasJellyBeanMr1()) {
                tvLeft.setCompoundDrawablesRelativeWithIntrinsicBounds(leftDrawable, 0, 0, 0);
            } else {
                tvLeft.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, 0, 0, 0);
            }
            tvLeft.setPadding(0, 0, PADDING_5, 0);
        } else {
            tvLeft.setPadding(PADDING_5, 0, PADDING_5, 0);
        }

        rlMain.addView(tvLeft, leftInnerParams);
        mFadeViewList.add(tvLeft);
    } else if (leftType == TYPE_LEFT_IMAGEBUTTON) {
        // 初始化左边ImageButton
        btnLeft = new ImageButton(context);
        btnLeft.setId(ViewFinder.generateViewId());
        btnLeft.setBackgroundColor(Color.TRANSPARENT);
        btnLeft.setImageResource(leftImageResource);
        btnLeft.setPadding(PADDING_12, 0, PADDING_12, 0);
        btnLeft.setOnClickListener(this);

        rlMain.addView(btnLeft, leftInnerParams);
        mFadeViewList.add(btnLeft);
    } else if (leftType == TYPE_LEFT_CUSTOM_VIEW) {
        // 初始化自定义View
        viewCustomLeft = LayoutInflater.from(context).inflate(leftCustomViewRes, null);
        if (viewCustomLeft.getId() == 0) {
            viewCustomLeft.setId(ViewFinder.generateViewId());
        }
        rlMain.addView(viewCustomLeft, leftInnerParams);
        mFadeViewList.add(viewCustomLeft);
    }
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:57,代码来源:CommonTitleBar.java

示例12: 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();
    }
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:51,代码来源:RightLeftButtonsBar.java

示例13: initViews

import android.widget.ImageButton; //导入方法依赖的package包/类
private void initViews() {
    if (InterfaceUtils.getTabletMode(this) == false)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mAlbumArtWorker = new Worker("album art worker");
    mAlbumArtHandler = new AlbumArtHandler(mAlbumArtWorker.getLooper());
    setContentView(R.layout.lockscreen);


    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LOW_PROFILE);
    } else {
        final View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }
    mAlbum = (ImageView) findViewById(R.id.album);
    mCurrentTime = (TextView) findViewById(R.id.currenttime);
    mTotalTime = (TextView) findViewById(R.id.totaltime);
    mProgress = (ProgressBar) findViewById(android.R.id.progress);
    mTrackName = (TextView) findViewById(R.id.trackname);
    mAlbumName = (TextView) findViewById(R.id.albumname);

    mCurrentTime.setTextColor(getResources().getColor(R.color.dark_text_color));
    mTotalTime.setTextColor(getResources().getColor(R.color.dark_text_color));
    mTrackName.setTextColor(getResources().getColor(R.color.dark_text_color));
    mAlbumName.setTextColor(getResources().getColor(R.color.dark_text_color));

    mPrevButton = (ImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(mPrevListener);
    mPauseButton = (FloatingActionButton) findViewById(R.id.FAB);
    InterfaceUtils.setUpFAB(this,
            R.drawable.music_playlist_holo_dark, mPauseButton, mPauseListener);

    mNextButton = (ImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(mNextListener);

    mPrevButton.setImageResource(R.drawable.btn_playback_previous_black);
    mNextButton.setImageResource(R.drawable.btn_playback_next_black);

    mShuffleButton = ((ImageButton) findViewById(R.id.shuffle));
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = ((ImageButton) findViewById(R.id.repeat));
    mRepeatButton.setOnClickListener(mRepeatListener);
    mCamera = ((ImageButton) findViewById(R.id.camera));
    mCamera.setOnClickListener(mCameraListener);
    mCamera.setOnLongClickListener(mCameraLongListener);

    mMainWindows = (RelativeLayout) findViewById(R.id.window);
    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
        seeker.setThumb(ThemeUtils.colorizeDrawable(getResources().getDrawable(R.drawable.thumb_seek), this));
        seeker.setProgressDrawable(ThemeUtils.colorizeDrawable(
                seeker.getProgressDrawable(), this));
    }
    mGestureScanner = new GestureDetector(this);
    mProgress.setMax(1000);
    setRepeatButtonImage();
    setShuffleButtonImage();
    setPauseButtonImage();
    if (MusicUtils.getBooleanPref(this, "radiomode", false)) {
        mProgress.setVisibility(View.INVISIBLE);
        mCurrentTime.setVisibility(View.INVISIBLE);
        mTotalTime.setVisibility(View.INVISIBLE);
        mRepeatButton.setVisibility(View.INVISIBLE);
        mShuffleButton.setVisibility(View.INVISIBLE);
    }
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:72,代码来源:MediaLockscreenActivity.java

示例14: addIconTab

import android.widget.ImageButton; //导入方法依赖的package包/类
private void addIconTab(final int position, int resId) {

        ImageButton tab = new ImageButton(getContext());
        tab.setImageResource(resId);

        addTab(position, tab);

    }
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:9,代码来源:PagerSlidingTabStrip.java

示例15: addIconTab

import android.widget.ImageButton; //导入方法依赖的package包/类
private void addIconTab(final int position, int resId) {

		ImageButton tab = new AppCompatImageButton(getContext());
		tab.setImageResource(resId);

		addTab(position, tab);

	}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:9,代码来源:PagerSlidingTabStrip.java


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