Java Code Examples for android.widget.ImageView.setSelected()

The following are Jave code examples for showing how to use setSelected() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MyFire   File: AdViewpagerUtil.java   View Source Code Vote up 7 votes
/**
 * 初始化标识点
 *
 * @param length
 */
public void initDots(int length) {
    if (dotlayout == null)
        return;
    dotlayout.removeAllViews();
    LinearLayout.LayoutParams mParams = new LinearLayout.LayoutParams(dip2px(context, dotsize), dip2px(context, dotsize));
    mParams.setMargins(dip2px(context, dotoffset), 0, dip2px(context, dotoffset), 0);//设置小圆点左右之间的间隔

    dotViews = new ImageView[length];

    for (int i = 0; i < length; i++) {
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(mParams);
        imageView.setImageResource(R.drawable.dot_selector);
        if (i == 0) {
            imageView.setSelected(true);//默认启动时,选中第一个小圆点
        } else {
            imageView.setSelected(false);
        }
        dotViews[i] = imageView;//得到每个小圆点的引用,用于滑动页面时,(onPageSelected方法中)更改它们的状态。
        dotlayout.addView(imageView);//添加到布局里面显示
    }
}
 
Example 2
Project: PlusGram   File: PagerSlidingTabStrip.java   View Source Code Vote up 7 votes
private void addIconTab(final int position, int resId) {
    ImageView tab = new ImageView(getContext()) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (pager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position);
            }
        }
    };
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 3
Project: Weekdays-Selector   File: WeekdaysPicker.java   View Source Code Vote up 6 votes
private void setDaySelected(ImageView dayView, boolean b) {
    dayView.setSelected(b);
    String dayText = getDayText(dayView);
    int tag = (int) dayView.getTag();
    if (b) {
        dayView.setImageDrawable(selectedBuilder.build(dayText, selectedDayBackgroundColor));
        selectedDays.add(tag);
    } else {
        dayView.setImageDrawable(unselectedBuilder.build(dayText, unSelectedDayBackgroundColor));
        selectedDays.remove(tag);
    }
}
 
Example 4
Project: ywApplication   File: Info1Activity.java   View Source Code Vote up 6 votes
private void initHeadView(ViewGroup topView,Data data) {
    topImage= (ImageView) topView.findViewById(R.id.head_image);
    listImageView= (ImageView) topView.findViewById(R.id.list_selector);
    gridImageView= (ImageView) topView.findViewById(R.id.grid_selector);
    text= (TextView) topView.findViewById(R.id.textView_info1);
    text.setText(data.getMember_share_tag().getDesc());
    String topImageth=data.getMember_share_tag().getImage_url();
    bitmapUtils.display(topImage,topImageth);
    listImageView.setSelected(true);
}
 
Example 5
Project: airgram   File: PagerSlidingTabStrip.java   View Source Code Vote up 6 votes
private void addIconTab(final int position, int resId) {
    ImageView tab = new ImageView(getContext());
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 6
Project: airgram   File: ScrollSlidingTabStrip.java   View Source Code Vote up 6 votes
public void addIconTab(int resId) {
    final int position = tabCount++;
    ImageView tab = new ImageView(getContext());
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 7
Project: Agora-Video-Source-Android   File: VideoChatViewActivity.java   View Source Code Vote up 6 votes
public void onLocalAudioMuteClicked(View view) {
    ImageView iv = (ImageView) view;
    if (iv.isSelected()) {
        iv.setSelected(false);
        iv.clearColorFilter();
    } else {
        iv.setSelected(true);
        iv.setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
    }

    mRtcEngine.muteLocalAudioStream(iv.isSelected());
}
 
Example 8
Project: Agora-Video-Source-Android   File: VideoChatViewActivity.java   View Source Code Vote up 6 votes
public void onLocalViewHidden(View view) {
    ImageView iv = (ImageView) view;
    if (iv.isSelected()) {
        iv.setSelected(false);
        iv.clearColorFilter();
        mCustomizedCameraRenderer.setViewHiddenStatus(false);
    } else {
        iv.setSelected(true);
        iv.setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
        mCustomizedCameraRenderer.setViewHiddenStatus(true);
    }
}
 
Example 9
Project: PlusGram   File: ScrollSlidingTabStrip.java   View Source Code Vote up 6 votes
public void addIconTab(int resId) {
    final int position = tabCount++;
    ImageView tab = new ImageView(getContext());
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 10
Project: microbit   File: PairingActivity.java   View Source Code Vote up 6 votes
/**
 * Sets a clicked cell on/off.
 *
 * @param image An image of a clicked cell.
 * @param pos   Position of a clicked cell.
 * @return True, if cell is on and false otherwise.
 */
private boolean toggleLED(ImageView image, int pos) {
    boolean isOn;
    //Toast.makeText(this, "Pos :" +  pos, Toast.LENGTH_SHORT).show();
    int state = (Integer) image.getTag(R.id.ledState);
    if(state != 1) {
        DEVICE_CODE_ARRAY[pos] = 1;
        image.setBackground(getApplication().getResources().getDrawable(R.drawable.red_white_led_btn));
        image.setTag(R.id.ledState, 1);
        isOn = true;

    } else {
        DEVICE_CODE_ARRAY[pos] = 0;
        image.setBackground(getApplication().getResources().getDrawable(R.drawable.white_red_led_btn));
        image.setTag(R.id.ledState, 0);
        isOn = false;
        // Update the code to consider the still ON LED below the toggled one
        if(pos < 20) {
            DEVICE_CODE_ARRAY[pos + 5] = 1;
        }
    }

    image.setSelected(false);
    int position = (Integer) image.getTag(R.id.position);
    image.setContentDescription("" + position + getLEDStatus(pos));
    return isOn;
}
 
Example 11
Project: Agora-Android-Voice-Tutorial-1to1   File: VoiceChatViewActivity.java   View Source Code Vote up 6 votes
public void onLocalAudioMuteClicked(View view) {
    ImageView iv = (ImageView) view;
    if (iv.isSelected()) {
        iv.setSelected(false);
        iv.clearColorFilter();
    } else {
        iv.setSelected(true);
        iv.setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
    }

    mRtcEngine.muteLocalAudioStream(iv.isSelected());
}
 
Example 12
Project: Agora-Android-Voice-Tutorial-1to1   File: VoiceChatViewActivity.java   View Source Code Vote up 6 votes
public void onSwitchSpeakerphoneClicked(View view) {
    ImageView iv = (ImageView) view;
    if (iv.isSelected()) {
        iv.setSelected(false);
        iv.clearColorFilter();
    } else {
        iv.setSelected(true);
        iv.setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
    }

    mRtcEngine.setEnableSpeakerphone(view.isSelected());
}
 
Example 13
Project: ViewPagerHelper   File: NormalIndicator.java   View Source Code Vote up 6 votes
public void addPagerData(PageBean bean, ViewPager viewPager){
    if (bean != null) {
        mCount = bean.datas.size();
        //这里加小圆点
        LayoutParams params = new
                LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(mLeftMargin,0,0,0);
        for (int i = 0; i < mCount; i++) {
            ImageView imageView = new ImageView(mContext);
            if (i == 0){
                imageView.setSelected(true);
            }else{
                imageView.setSelected(false);
            }
            imageView.setLayoutParams(params);
            imageView.setBackgroundResource(mSelector);

            addView(imageView);
        }

        if (viewPager != null) {
            viewPager.addOnPageChangeListener(this);
        }
    }
    if (bean.openview != null){
        mOpenView = bean.openview;
    }
}