android.widget.ImageButton# setSelected ( ) 源码实例Demo

下面列出了android.widget.ImageButton# setSelected ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void addIconTab(final int position, int resId) {

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

        tab.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                pager.setCurrentItem(position);
            }
        });

        tabsContainer.addView(tab);
        tab.setSelected(position == currentPosition);
    }
 
源代码2 项目: yiim_v2   文件: CreateRoomActivity.java
@Override
protected void initViews() {
	// TODO Auto-generated method stub
	mIcon1 = (ImageButton) findViewById(R.id.create_room_icon1);
	mIcon1.setSelected(false);
	mIcon2 = (ImageButton) findViewById(R.id.create_room_icon2);
	mIcon2.setSelected(true);
	mIcon3 = (ImageButton) findViewById(R.id.create_room_icon3);
	mIcon3.setSelected(true);
	mIcon4 = (ImageButton) findViewById(R.id.create_room_icon4);
	mIcon4.setSelected(true);

	mLastSelectedIcon = mIcon1;

	mRoomNameEditText = (EditText) findViewById(R.id.create_room_room_name);
	mRoomSignEditText = (EditText) findViewById(R.id.create_room_room_sign);
}
 
public void onClickNotifyCharacteristic(View view) {
    ElementPath elementPath = (ElementPath) view.getTag();

    if (elementPath != null) {
        // Check if is a characteristic
        if (elementPath.characteristicUUID != null && elementPath.descriptorUUID == null) {
            BluetoothGattService service = mBleManager.getGattService(elementPath.serviceUUID, elementPath.serviceInstance);
            if (mBleManager.isCharacteristicNotifiable(service, elementPath.characteristicUUID)) {
                Log.d(TAG, "Notify char");
                ImageButton imageButton = (ImageButton) view;
                final boolean selected = !imageButton.isSelected();
                imageButton.setSelected(selected);
                mBleManager.enableNotification(service, elementPath.characteristicUUID, selected);

                // Button color effect when pressed
                imageButton.setImageResource(selected ? R.drawable.ic_sync_white_24dp : R.drawable.ic_sync_black_24dp);
            }
        }
    }
}
 
源代码4 项目: IslamicLibraryAndroid   文件: ReadingActivity.java
@Override
public void setBookmarkState(boolean Checked) {
    if (is_nav_view_inflated) {
        ImageButton bookmarkImageButton = mControlsView.findViewById(R.id.action_bookmark_this_page);
        if (bookmarkImageButton.isSelected() != Checked)
            bookmarkImageButton.setSelected(Checked);
    }
}
 
源代码5 项目: microMathematics   文件: DialogBase.java
protected void setButtonSelected(ImageButton b, boolean isSelected)
{
    b.setSelected(isSelected);
    if (b.isSelected())
    {
        b.setBackgroundResource(R.drawable.formula_term_border);
        CompatUtils.setDrawableColorAttr(getContext(), b.getBackground(), R.attr.colorAccent);
    }
    else
    {
        b.setBackgroundResource(android.R.color.transparent);
    }
    ViewUtils.setImageButtonColorAttr(getContext(), b,
            b.isSelected() ? R.attr.colorAccent : R.attr.colorDialogContent);
}
 
源代码6 项目: KitKatEmoji   文件: PagerSlidingTabStrip.java
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);
    }
 
源代码7 项目: sealrtc-android   文件: AudioMixActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_audio_mix);

    AudioMixActivity.alive = true;

    img_btn_play_pause = (ImageButton) findViewById(R.id.img_btn_play_pause);
    img_btn_stop = (ImageButton) findViewById(R.id.img_btn_stop);
    btn_select_music = (Button) findViewById(R.id.btn_select_music);
    btn_change_mode = (Button) findViewById(R.id.btn_change_mode);
    sb_mix_local_vol = (SeekBar) findViewById(R.id.sb_mix_local_vol);
    sb_mix_remote_vol = (SeekBar) findViewById(R.id.sb_mix_remote_vol);
    sb_mic_vol = (SeekBar) findViewById(R.id.sb_mic_vol);
    tv_mix_local_vol = (TextView) findViewById(R.id.tv_mix_local_vol);
    tv_mix_remote_vol = (TextView) findViewById(R.id.tv_mix_remote_vol);
    tv_mic_vol = (TextView) findViewById(R.id.tv_mic_vol);

    img_btn_stop.setEnabled(mixing);
    img_btn_play_pause.setSelected(mixing);

    sb_mic_vol.setOnSeekBarChangeListener(this);
    sb_mix_remote_vol.setOnSeekBarChangeListener(this);
    sb_mix_local_vol.setOnSeekBarChangeListener(this);

    tv_mic_vol.setText("0");
    int mixRemoteVol = RCRTCAudioMixer.getInstance().getMixingVolume();
    tv_mix_remote_vol.setText(String.valueOf(mixRemoteVol));
    sb_mix_remote_vol.setProgress(mixRemoteVol);

    int mixLocalVol = RCRTCAudioMixer.getInstance().getPlaybackVolume();
    tv_mix_local_vol.setText(String.valueOf(mixLocalVol));
    sb_mix_local_vol.setProgress(mixLocalVol);

    int recordingVol = RongRTCCapture.getInstance().getRecordingVolume();
    tv_mic_vol.setText(String.valueOf(recordingVol));
    sb_mic_vol.setProgress(recordingVol);

    mixModes[0] = getResources().getString(R.string.mix_mode_play_mix);
    mixModes[1] = getResources().getString(R.string.mix_mode_mix_only);
    mixModes[2] = getResources().getString(R.string.mix_mode_play_only);
    mixModes[3] = getResources().getString(R.string.mix_mode_replace);

    btn_select_music.setText(getFileName(audioPath));
    btn_change_mode.setText(mixModes[mixMode]);
}