Java Code Examples for android.widget.ImageButton#setImageResource()

The following examples show how to use android.widget.ImageButton#setImageResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersonDetail.java    From kute with Apache License 2.0 6 votes vote down vote up
public Boolean handleOtherDetailsDropdown(Boolean is_otherdetail_dropdown, ImageButton icon, final TableRow other_details_text) {
    if (is_otherdetail_dropdown) {
        other_details_text.setVisibility(View.GONE);
        icon.setImageResource(R.drawable.ic_arrow_drop_down_black_24dp);
        return false;
    } else {
        other_details_text.setVisibility(View.VISIBLE);
        icon.setImageResource(R.drawable.ic_arrow_drop_up_black_24dp);
        //Adjusting the scrollview for smaller screens
        scroll_view.post(new Runnable() {
            @Override
            public void run() {
                scroll_view.scrollTo(0, other_details_text.getBottom());
            }
        });
        return true;
    }
}
 
Example 2
Source File: ExpandableSelector.java    From ExpandableSelector with Apache License 2.0 5 votes vote down vote up
private void configureButtonContent(View button, ExpandableItem expandableItem) {
  if (expandableItem.hasBackgroundId()) {
    int backgroundId = expandableItem.getBackgroundId();
    button.setBackgroundResource(backgroundId);
  }
  if (expandableItem.hasTitle()) {
    String text = expandableItem.getTitle();
    ((Button) button).setText(text);
  }
  if (expandableItem.hasResourceId()) {
    ImageButton imageButton = (ImageButton) button;
    int resourceId = expandableItem.getResourceId();
    imageButton.setImageResource(resourceId);
  }
}
 
Example 3
Source File: ReadActivity.java    From Jreader with GNU General Public License v2.0 5 votes vote down vote up
/**
 * popupwindow的弹出,工具栏
 */
public void pop() {

    mPopupWindow.showAtLocation(mPageWidget, Gravity.NO_GRAVITY, 0, 0);
    fontSize = (TextView) popupwindwow.findViewById(R.id.bookBtn_size);
    readLight = (TextView) popupwindwow.findViewById(R.id.bookBtn_light);
    bookMark = (TextView) popupwindwow.findViewById(R.id.bookBtn_mark);
    readJump = (TextView) popupwindwow.findViewById(R.id.bookBtn_jump);
    readSet = (TextView) popupwindwow.findViewById(R.id.readSet);
    layout = (LinearLayout) popupwindwow.findViewById(R.id.bookpop_bottom);//主要为了夜间模式时设置背景
    fontSize.setTypeface(typeface);//设置字体
    readLight.setTypeface(typeface);
    bookMark.setTypeface(typeface);
    readJump.setTypeface(typeface);
    readSet.setTypeface(typeface);

    TextView blank_view = (TextView) popupwindwow.findViewById(R.id.blank_view);
    listener_book = (ImageButton) popupwindwow.findViewById(R.id.listener_book);
    pop_return = (ImageButton) popupwindwow.findViewById(R.id.pop_return);
    imageBtn_light = (ImageButton) popupwindwow.findViewById((R.id.imageBtn_light));
    getDayOrNight();
    if (isNight) {
        layout.setBackgroundResource(R.drawable.tmall_bar_bg);
        imageBtn_light.setImageResource(R.drawable.menu_light_icon2);
    } else {
        layout.setBackgroundResource(R.drawable.tmall_bar_bg);
        imageBtn_light.setImageResource(R.drawable.menu_daynight_icon);
    }
    fontSize.setOnClickListener(this);
    readLight.setOnClickListener(this);
    bookMark.setOnClickListener(this);
    readJump.setOnClickListener(this);
    readSet.setOnClickListener(this);
    blank_view.setOnClickListener(this);
    listener_book.setOnClickListener(this);
    pop_return.setOnClickListener(this);
    imageBtn_light.setOnClickListener(this);
}
 
Example 4
Source File: NotifyUtils.java    From Conquer with Apache License 2.0 5 votes vote down vote up
public static void pauseAudio(ImageButton ib_play) {
	// 暂停播放,保存播放进度
	if (player != null && player.isPlaying()) {
		curPosition = player.getCurrentPosition();
		player.pause();
		if (timer_play != null) {
			timer_play.cancel();
			timer_play = null;
		}
		if (ib_play != null) {
			ib_play.setImageResource(R.drawable.play_audio);
			ib_play.setTag("play");
		}
	}
}
 
Example 5
Source File: DatetimePickerDialog.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
private void updateButton() {
    ImageButton button = getIconButton(BUTTON_POSITIVE);
    if (button != null) {
        int iconResId;
        if (mOnLastPage) {
            iconResId = mLastBtnIconResId > 0 ? mLastBtnIconResId : R.drawable.tic_ic_btn_ok;
        } else {
            iconResId = mNextBtnIconResId > 0 ? mNextBtnIconResId : R.drawable.tic_ic_btn_next;
        }
        button.setImageResource(iconResId);
        button.setOnClickListener(this);
    }
}
 
Example 6
Source File: PagerSlidingTabStrip.java    From KitKatEmoji with MIT License 5 votes vote down vote up
private void addIconTab(final int position, int resId) {

        ImageButton tab = new ImageButton(getContext());
        tab.setImageResource(resId);
        tab.setFocusable(true);
        addTab(position, tab);
        tab.setSelected(position == currentPosition);
    }
 
Example 7
Source File: MainActivity.java    From ki4a with Apache License 2.0 5 votes vote down vote up
protected static void refresh_status_img(int status)
{
    button = (ImageButton) myMainActivity.findViewById(R.id.imageButton_status);
    text_status = (TextView) myMainActivity.findViewById(R.id.textView_status);
    if(status==Util.STATUS_DISCONNECT)
    {
        text_status.setText(R.string.text_status_empty);
        button.setImageResource(R.drawable.status_red);
    }
    else if(status==Util.STATUS_INIT)
    {
        text_status.setText(R.string.text_status_initializing);
        button.setImageResource(R.drawable.status_gray);
    }
    else if(status==Util.STATUS_CONNECTING)
    {
        text_status.setText(R.string.text_status_connecting);
        button.setImageResource(R.drawable.status_orange);
    }
    else if(status==Util.STATUS_SOCKS)
    {
        text_status.setText(R.string.text_status_connected);
        button.setImageResource(R.drawable.status_blue);
        if (adClientView != null) {
            adClientView.load();
        }
    }
}
 
Example 8
Source File: RichEditWidgetView.java    From android-notepad with MIT License 5 votes vote down vote up
public RichEditWidgetView(Context context, AttributeSet attrs, int defStyleAttr){
	super(context, attrs, defStyleAttr);
	View view = LayoutInflater.from(context).inflate(R.layout.view_rich_edit_widget, this, true);
	ButterKnife.bind(this, view);
	setVisibility(GONE);
	for (int i = 0; i < supportedEffects.length; i++){
		LayoutInflater.from(context).inflate(R.layout.view_rich_edit_action_button, linearLayout, true);
		ImageButton action = (ImageButton) linearLayout.getChildAt(linearLayout.getChildCount() - 1);
		action.setTag(supportedEffects[i]);
		action.setImageResource(effectIcons[i]);
		action.setOnClickListener(actionClickListener);
	}
}
 
Example 9
Source File: CommonPlaybackButtonsListener.java    From android-vlc-remote with GNU General Public License v3.0 5 votes vote down vote up
private void setupImageButtonListeners(ImageButton... imageButtons) {
    for(ImageButton b : imageButtons) {
        if(b != null) {
            Button info = Buttons.getButton(b.getId(), Preferences.get(b.getContext()));
            b.setImageResource(info.getIconId());
            b.setContentDescription(b.getContext().getString(info.getContentDescriptionId()));
            b.setOnClickListener(this);
            b.setOnLongClickListener(this);
        }
    }
}
 
Example 10
Source File: MenuItemView.java    From SpringFloatingActionMenu with Apache License 2.0 4 votes vote down vote up
private void init(Context context) {

        Resources resources = getResources();
        int diameterPX = Utils.dpToPx(mMenuItem.getDiameter(), resources);
        this.mDiameter = diameterPX;
        mBtn = new ImageButton(context);
        LayoutParams btnLp = new LayoutParams(diameterPX, diameterPX);
        btnLp.gravity = Gravity.CENTER_HORIZONTAL;
        btnLp.bottomMargin = Util.dpToPx(mGapSize, resources);
        mBtn.setLayoutParams(btnLp);
        OvalShape ovalShape = new OvalShape();
        ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
        shapeDrawable.getPaint().setColor(resources.getColor(mMenuItem.getBgColor()));
        mBtn.setBackgroundDrawable(shapeDrawable);
        mBtn.setImageResource(mMenuItem.getIcon());
        mBtn.setClickable(false);
        addView(mBtn);

        mLabel = new TextView(context);
        LayoutParams labelLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        labelLp.gravity = Gravity.CENTER_HORIZONTAL;
        mLabel.setLayoutParams(labelLp);
        mLabel.setText(mMenuItem.getLabel());
        mLabel.setTextColor(resources.getColor(mMenuItem.getTextColor()));
        mLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize);
        addView(mLabel);

        setOrientation(LinearLayout.VERTICAL);
        if(mAlphaAnimation) {
            setAlpha(0);
        }

        getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
                applyPressAnimation();
                ViewGroup parent = (ViewGroup) getParent();
                parent.setClipChildren(false);
                parent.setClipToPadding(false);
                setClipChildren(false);
                setClipToPadding(false);
            }
        });


    }
 
Example 11
Source File: NoteAdapter.java    From Swiftnotes with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // Inflate custom note view if null
    if (convertView == null)
        convertView = this.inflater.inflate(R.layout.list_view_note, parent, false);

    // Initialize layout items
    RelativeLayout relativeLayout = (RelativeLayout) convertView.findViewById(R.id.relativeLayout);
    LayerDrawable roundedCard = (LayerDrawable) context.getResources().getDrawable(R.drawable.rounded_card);
    TextView titleView = (TextView) convertView.findViewById(R.id.titleView);
    TextView bodyView = (TextView) convertView.findViewById(R.id.bodyView);
    ImageButton favourite = (ImageButton) convertView.findViewById(R.id.favourite);

    // Get Note object at position
    JSONObject noteObject = getItem(position);

    if (noteObject != null) {
        // If noteObject not empty -> initialize variables
        String title = context.getString(R.string.note_title);
        String body = context.getString(R.string.note_body);
        String colour = String.valueOf(context.getResources().getColor(R.color.white));
        int fontSize = 18;
        Boolean hideBody = false;
        Boolean favoured = false;

        try {
            // Get noteObject data and store in variables
            title = noteObject.getString(NOTE_TITLE);
            body = noteObject.getString(NOTE_BODY);
            colour = noteObject.getString(NOTE_COLOUR);

            if (noteObject.has(NOTE_FONT_SIZE))
                fontSize = noteObject.getInt(NOTE_FONT_SIZE);

            if (noteObject.has(NOTE_HIDE_BODY))
                hideBody = noteObject.getBoolean(NOTE_HIDE_BODY);

            favoured = noteObject.getBoolean(NOTE_FAVOURED);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        // Set favourite image resource
        if (favoured)
            favourite.setImageResource(R.drawable.ic_fav);

        else
            favourite.setImageResource(R.drawable.ic_unfav);


        // If search or delete modes are active -> hide favourite button; Show otherwise
        if (searchActive || deleteActive)
            favourite.setVisibility(View.INVISIBLE);

        else
            favourite.setVisibility(View.VISIBLE);


        titleView.setText(title);

        // If hidBody is true -> hide body of note
        if (hideBody)
            bodyView.setVisibility(View.GONE);

        // Else -> set visible note body, text to normal and set text size to 'fontSize' as sp
        else {
            bodyView.setVisibility(View.VISIBLE);
            bodyView.setText(body);
            bodyView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
        }

        // If current note is selected for deletion -> highlight
        if (checkedArray.contains(position)) {
            ((GradientDrawable) roundedCard.findDrawableByLayerId(R.id.card))
                    .setColor(context.getResources().getColor(R.color.theme_primary));
        }

        // If current note is not selected -> set background colour to normal
        else {
            ((GradientDrawable) roundedCard.findDrawableByLayerId(R.id.card))
                    .setColor(Color.parseColor(colour));
        }

        // Set note background style to rounded card
        relativeLayout.setBackground(roundedCard);

        final Boolean finalFavoured = favoured;
        favourite.setOnClickListener(new View.OnClickListener() {
            // If favourite button was clicked -> change that note to favourite or un-favourite
            @Override
            public void onClick(View v) {
                setFavourite(context, !finalFavoured, position);
            }
        });
    }

    return convertView;
}
 
Example 12
Source File: MeasurementActivity.java    From NoiseCapture with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    Resources resources = activity.getResources();
    ImageButton buttonPause= (ImageButton) activity.findViewById(R.id.pauseBtn);
    buttonPause.setEnabled(true);
    ImageButton buttonrecord= (ImageButton) activity.findViewById(R.id.recordBtn);

    if (!activity.measurementService.isStoring()) {
        // Start recording
        buttonrecord.setImageResource(R.drawable.button_record_pressed);
        buttonrecord.setEnabled(false);
        activity.measurementService.startStorage();
        // Force service to stay alive even if this activity is killed (Foreground service)
        activity.startService(new Intent(activity, MeasurementService.class));
    } else {
        // Stop measurement
        activity.measurementService.stopRecording();

        // Show computing progress dialog
        ProgressDialog myDialog = new ProgressDialog(activity);
        if (!activity.measurementService.isCanceled()) {
            myDialog.setMessage(resources.getString(R.string.measurement_processlastsamples,
                    activity.measurementService.getAudioProcess().getRemainingNotProcessSamples()));
            myDialog.setCancelable(false);
            myDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                    resources.getText(R.string.text_CANCEL_data_transfer),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            activity.measurementService.cancel();
                        }
                    });
            myDialog.show();
        }

        // Launch processing end activity
        new Thread(new WaitEndOfProcessing(activity, myDialog)).start();
    }
    activity.initGuiState();
}
 
Example 13
Source File: PagerSlidingTabStrip.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
private void a(int i1, int j1)
{
    ImageButton imagebutton = new ImageButton(getContext());
    imagebutton.setImageResource(j1);
    a(i1, ((View) (imagebutton)));
}
 
Example 14
Source File: PagerSlidingTabStrip.java    From android-expression with Apache License 2.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

		addTab(position, tab);

	}
 
Example 15
Source File: PagerSlidingTabStrip.java    From GreenDamFileExploere with Apache License 2.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

        addTab(position, tab);

    }
 
Example 16
Source File: TabStrip.java    From SuperToasts with Apache License 2.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

        addTab(position, tab);
    }
 
Example 17
Source File: PagerSlidingTabStrip.java    From AndroidBase with Apache License 2.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

		addTab(position, tab);

	}
 
Example 18
Source File: PagerSlidingTabStrip.java    From 920-text-editor-v2 with Apache License 2.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

        addTab(position, tab);

    }
 
Example 19
Source File: PagerSlidingTabStrip.java    From actor-platform with GNU Affero General Public License v3.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

        addTab(position, tab);

    }
 
Example 20
Source File: PagerSlidingTabStrip.java    From RefreashTabView with Apache License 2.0 3 votes vote down vote up
private void addIconTab(final int position, int resId) {

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

		addTab(position, tab);

	}