Java Code Examples for android.widget.TextView#setSelected()

The following examples show how to use android.widget.TextView#setSelected() . These examples are extracted from open source projects. 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
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_description, container, false);

    mTitleView = (TextView) rootView.findViewById(R.id.title);
    mSummaryView = (TextView) rootView.findViewById(R.id.summary);

    if (Utils.isTv(getActivity())) {
        mSummaryView.setFocusable(true);
    } else {
        mTitleView.setTextIsSelectable(true);
        mSummaryView.setTextIsSelectable(true);
    }

    mSummaryView.setSelected(true);
    mSummaryView.setMovementMethod(LinkMovementMethod.getInstance());

    mTitle = getArguments().getCharSequence("title");
    mSummary = getArguments().getCharSequence("summary");

    refresh();
    return rootView;
}
 
Example 2
Source Project: SAI   File: Coolbar.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void init() {
    mTitle = new TextView(getContext());
    mTitle.setText(mTitleText);
    mTitle.setBackgroundColor(Color.TRANSPARENT);
    mTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TITLE_TEXT_SIZE_SP);
    mTitle.setTextColor(mTitleColor);
    mTitle.setGravity(Gravity.CENTER);
    mTitle.setSingleLine();
    mTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    mTitle.setMarqueeRepeatLimit(-1);
    mTitle.setSelected(true);
    addView(mTitle);

    if (getBackground() == null)
        setBackgroundColor(getThemeColor(R.attr.colorPrimary, Color.WHITE));
}
 
Example 3
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
  // Inflate the layout for this fragment
  View view = inflater.inflate(R.layout.fragment_onboarding_asr_calculation_method, container, false);

  view.findViewById(R.id.prev).setOnClickListener(this);
  view.findViewById(R.id.next).setOnClickListener(this);

  TextView title = (TextView) view.findViewById(R.id.card_title);
  title.setText(R.string.asr_method);

  mHanfi = (TextView) view.findViewById(R.id.asr_hanfi);
  mShafii = (TextView) view.findViewById(R.id.asr_shafii);
  mHanfi.setOnClickListener(this);
  mShafii.setOnClickListener(this);

  int method = AppSettings.getInstance(getActivity()).getAsrMethodSetFor(mParam1);
  if (method == PrayTime.SHAFII) {
    mShafii.setSelected(true);
  } else {
    mHanfi.setSelected(true);
  }

  return view;
}
 
Example 4
@Override
public void clickLongMyChannel(RecyclerView mRecyclerView, ChannelViewHolder holder) {
    if (!isEditMode) {
        doStartEditMode(mRecyclerView);
        View view = mRecyclerView.getChildAt(0);
        if (view == mRecyclerView.getLayoutManager().findViewByPosition(0)) {
            TextView dragTip = (TextView) view.findViewById(R.id.id_my_header_tip_tv);
            dragTip.setText("拖拽可以排序");

            TextView tvBtnEdit = (TextView) view.findViewById(R.id.id_edit_mode);
            tvBtnEdit.setText("完成");
            tvBtnEdit.setSelected(true);
        }
        mItemTouchHelper.startDrag(holder);
    }
}
 
Example 5
public void initView() {
    mType = (TextView) activity.findViewById(R.id.rmp_type);

    mName = (TextView) activity.findViewById(R.id.rmp_info_name);
    // 跑马灯
    mName.setSelected(true);
    mArts = (TextView) activity.findViewById(R.id.rmp_info_arts);
    mRemark = (TextView) activity.findViewById(R.id.rmp_info_remark);

    mPlayTime = (TextView) activity.findViewById(R.id.rmp_play_time);
    mPlayTimeL = (TextView) activity.findViewById(R.id.rmp_l_time);
    mPlayTimeR = (TextView) activity.findViewById(R.id.rmp_r_time);

    mShowMore = (TextView) activity.findViewById(R.id.rmp_see_more);
    mLine = activity.findViewById(R.id.rmp_line);
    mInfoLine = activity.findViewById(R.id.rmp_info_line);
    mImage = (ImageView) activity.findViewById(R.id.rmp_image);
    mInfoContainer = activity.findViewById(R.id.rmp_info_container);
    mContainer = activity.findViewById(R.id.rmp_container);

    mShowMore.setOnClickListener(this);
    mContainer.setOnClickListener(this);
}
 
Example 6
private void initSelfViews() {

        mAlbum = (ImageView) activity.findViewById(R.id.list_album);
        mName = (TextView) activity.findViewById(R.id.list_name);
        // 跑马灯
        mName.setSelected(true);
        mArts = (TextView) activity.findViewById(R.id.list_arts);
        mPlay = (PlayView) activity.findViewById(R.id.list_play);
        mShowList = (ImageButton) activity.findViewById(R.id.list_list);
        mContainer = activity.findViewById(R.id.list_bottom_nav_container);
        mProgress = activity.findViewById(R.id.list_progress);
        mProgressBG = activity.findViewById(R.id.list_progress_bg);

        mContainer.setOnClickListener(this);
        mShowList.setOnClickListener(this);
        mPlay.setOnClickListener(this);

    }
 
Example 7
@Override
public void onClick(View v) {
  if (v.getId() == R.id.next) {
    mListener.onOptionSelected();
    return;
  }
  for (TextView t : options) {
    if (t.getId() == v.getId()) {
      AppSettings settings = AppSettings.getInstance(getActivity());
      settings.setCalcMethodFor(mParam1, Integer.valueOf((String) t.getTag()));
      t.setSelected(true);
      mListener.onOptionSelected();
    } else {
      t.setSelected(false);
    }
  }
}
 
Example 8
Source Project: LiuAGeAndroid   File: OptionalGridViewAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = LayoutInflater.from(context).inflate(R.layout.item_column_item, null);
    item_text = (TextView) view.findViewById(R.id.text_item);
    String className = getItem(position).getClassname();
    item_text.setText(className);
    if (isSelected) {
        if (position == 0) {
            item_text.setEnabled(false);
        }
    }
    if (!isVisible && (position == -1 + optionalList.size())) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
    }
    if (remove_position == position) {
        item_text.setText("");
    }
    return view;
}
 
Example 9
public void onXPreferenceChanged(XPreference preference, boolean isChecked)
{
	TextView checkbox = preference.getIndicator();
	if (onXPreferenceSelected(preference, isChecked) && !isChecked)
	{
		checkbox.setSelected(true);
	}
	else
	{
		checkbox.setSelected(false);
	}
}
 
Example 10
Source Project: VCL-Android   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the alignment mode of the specified TextView with the desired align
 * mode from preferences.
 *
 * See @array/audio_title_alignment_values
 *
 * @param alignMode Align mode as read from preferences
 * @param t Reference to the textview
 */
public static void setAlignModeByPref(int alignMode, TextView t) {
    if(alignMode == 1)
        t.setEllipsize(TruncateAt.END);
    else if(alignMode == 2)
        t.setEllipsize(TruncateAt.START);
    else if(alignMode == 3) {
        t.setEllipsize(TruncateAt.MARQUEE);
        t.setMarqueeRepeatLimit(-1);
        t.setSelected(true);
    }
}
 
Example 11
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.main_menu_item, null);
    }


    //绑定item内的TextView和RadioButton
    TextView nameText = MenuDialogAdapterViewHolder.get(convertView, R.id.menu_item_textview);
    RadioButton clickButton = MenuDialogAdapterViewHolder.get(convertView, R.id.radioButton);
    clickButton.setChecked(selectedPos == position);//改变点击选中状态

    //修改item高度,使其达到甲方要求的每页10个item显示要求
    ViewGroup.LayoutParams lp = nameText.getLayoutParams();
    lp.height = parent.getHeight() / 10;

    //获取选中的item的标题
    CommodityTypeModel menuData = menuDatas.get(position);
    String str = menuData.getName();
    nameText.setText(str);//设置标题

    convertView.setSelected(selectedPos == position);//设置选中时的view
    nameText.setSelected(selectedPos == position);//判断菜单的点击状态

    //选中后的标题字体及RadioButton颜色
    nameText.setTextColor(selectedPos == position ? 0xFF387ef5 : 0xFF222222);
    clickButton.setTextColor(selectedPos == position ? 0xFF787878 : 0xFF387ef5);

    return convertView;
}
 
Example 12
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  int id = buttonView.getId();
  if (id == mAlarm.getId()) {
    settings.setAlarmFor(mIndex, isChecked);
    for (int i = 0; i < mPrayers.length; i++) {
      TextView tv = mPrayers[i];
      tv.setEnabled(isChecked);
      tv.setSelected(isChecked);
      setPrayerAlarmStatus(i, isChecked);
    }

    if (!isChecked) {
      mRamadanHelper.setRamadanOption(false);
    }
    mRamadanHelper.setRamadanOptionEnabled(isChecked);

  } else if (id == mAscending.getId()) {
    settings.set(AppSettings.Key.IS_ASCENDING_ALARM, isChecked);

  } else if (id == mRandom.getId()) {
    settings.set(AppSettings.Key.IS_RANDOM_ALARM, isChecked);
    if (isChecked) {
      mAdhan.setChecked(false);
    }

  } else if (id == mAdhan.getId()) {
    settings.set(AppSettings.Key.USE_ADHAN, isChecked);
    if (isChecked) {
      mRandom.setChecked(false);
    }
  }
}
 
Example 13
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
  // Inflate the layout for this fragment
  View view = inflater.inflate(R.layout.fragment_onboarding_time_format, container, false);

  view.findViewById(R.id.prev).setOnClickListener(this);
  TextView next = (TextView) view.findViewById(R.id.next);
  next.setOnClickListener(this);
  next.setText(R.string.button_done);

  TextView title = (TextView) view.findViewById(R.id.card_title);
  title.setText(R.string.time_title);

  m12h = (TextView) view.findViewById(R.id.twelve);
  m24h = (TextView) view.findViewById(R.id.twenty_four);
  m12h.setOnClickListener(this);
  m24h.setOnClickListener(this);

  int method = AppSettings.getInstance(getActivity()).getTimeFormatFor(mParam1);
  if (method == PrayTime.TIME_12) {
    m12h.setSelected(true);
  } else {
    m24h.setSelected(true);
  }

  return view;
}
 
Example 14
Source Project: LabelsView   File: LabelsView.java    License: Apache License 2.0 5 votes vote down vote up
private void setLabelSelect(TextView label, boolean isSelect) {
    if (label.isSelected() != isSelect) {
        label.setSelected(isSelect);
        if (isSelect) {
            mSelectLabels.add((Integer) label.getTag(KEY_POSITION));
        } else {
            mSelectLabels.remove((Integer) label.getTag(KEY_POSITION));
        }
        if (mLabelSelectChangeListener != null) {
            mLabelSelectChangeListener.onLabelSelectChange(label, label.getTag(KEY_DATA),
                    isSelect, (int) label.getTag(KEY_POSITION));
        }
    }
}
 
Example 15
Source Project: DanDanPlayForAndroid   File: LabelsView.java    License: MIT License 5 votes vote down vote up
private void setLabelSelect(TextView label, boolean isSelect) {
    if (label.isSelected() != isSelect) {
        label.setSelected(isSelect);
        if (isSelect) {
            mSelectLabels.add((Integer) label.getTag(KEY_POSITION));
        } else {
            mSelectLabels.remove((Integer) label.getTag(KEY_POSITION));
        }
        if (mLabelSelectChangeListener != null) {
            mLabelSelectChangeListener.onLabelSelectChange(label, label.getTag(KEY_DATA),
                    isSelect, (int) label.getTag(KEY_POSITION));
        }
    }
}
 
Example 16
Source Project: BaoKanAndroid   File: DragGridViewAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = LayoutInflater.from(context).inflate(R.layout.item_column_item, null);
    item_text = (TextView) view.findViewById(R.id.text_item);
    String className = getItem(position).getClassname();
    item_text.setText(className);
    if (isUser) {
        if ((position == 0) || (position == 1)) {
            item_text.setEnabled(false);
        }
    }
    if (isChanged && (position == holdPosition) && !isItemShow) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
        isChanged = false;
    }
    if (!isVisible && (position == -1 + selectedList.size())) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
    }
    if (remove_position == position) {
        item_text.setText("");
    }
    return view;
}
 
Example 17
Source Project: screenplay   File: NavigationMenuView.java    License: MIT License 5 votes vote down vote up
private void setSelected(int id) {
    selected = id;
    for (int i = 0; i < getChildCount(); i++) {
        TextView child = (TextView) getChildAt(i);
        if (id == child.getId()) {
            child.setSelected(true);
        } else {
            child.setSelected(false);
        }
    }
}
 
Example 18
Source Project: LiuAGeAndroid   File: DragGridViewAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = LayoutInflater.from(context).inflate(R.layout.item_column_item, null);
    item_text = (TextView) view.findViewById(R.id.text_item);
    String className = getItem(position).getClassname();
    item_text.setText(className);
    if (isUser) {
        if (position == 0) {
            item_text.setEnabled(false);
        }
    }
    if (isChanged && (position == holdPosition) && !isItemShow) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
        isChanged = false;
    }
    if (!isVisible && (position == -1 + selectedList.size())) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
    }
    if (remove_position == position) {
        item_text.setText("");
    }
    return view;
}
 
Example 19
Source Project: LineBreakLayout   File: LineBreakLayout.java    License: MIT License 4 votes vote down vote up
/**
 * 添加标签
 * @param lables 标签集合
 * @param add 是否追加
    */
public void setLables(List<String> lables, boolean add){
	if(this.lables == null){
		this.lables = new ArrayList<>();
	}
	if(add){
		this.lables.addAll(lables);
	}else{
		this.lables.clear();
		this.lables = lables;
	}
	if(lables!=null && lables.size()>0){
		LayoutInflater inflater = LayoutInflater.from(getContext());
		for (final String lable : lables) {
			//获取标签布局
			final TextView tv = (TextView) inflater.inflate(R.layout.item_lable, null);
			tv.setText(lable);
			//设置选中效果
			if (lableSelected.contains(lable)) {
				//选中
				tv.setSelected(true);
				tv.setTextColor(getResources().getColor(R.color.tv_blue));
			} else {
				//未选中
				tv.setSelected(false);
				tv.setTextColor(getResources().getColor(R.color.tv_gray));
			}
			//点击标签后,重置选中效果
			tv.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					tv.setSelected(tv.isSelected() ? false : true);
					if (tv.isSelected()) {
						tv.setTextColor(getResources().getColor(R.color.tv_blue));
						//将选中的标签加入到lableSelected中
						lableSelected.add(lable);
					} else {
						tv.setTextColor(getResources().getColor(R.color.tv_gray));
						lableSelected.remove(lable);
					}
				}
			});
			//将标签添加到容器中
			addView(tv);
		}
	}
}
 
Example 20
Source Project: XBanner   File: XBanner.java    License: Apache License 2.0 4 votes vote down vote up
private void initView() {

        /*设置指示器背景容器*/
        RelativeLayout pointContainerRl = new RelativeLayout(getContext());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
        } else {
            pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
        }

        /*设置内边距*/
        pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomPading, mPointContainerLeftRightPadding, mPointTopBottomPading);

        /*设定指示器容器布局及位置*/
        mPointContainerLp = new LayoutParams(RMP, RWC);
        mPointContainerLp.addRule(mPointContainerPosition);
        if (mIsClipChildrenMode) {
            mPointContainerLp.setMargins(mClipChildrenLeftRightMargin, 0, mClipChildrenLeftRightMargin, mClipChildrenTopBottomMargin);
        }
        addView(pointContainerRl, mPointContainerLp);
        mPointRealContainerLp = new LayoutParams(RWC, RWC);
        /*设置指示器容器*/
        if (mIsNumberIndicator) {
            mNumberIndicatorTv = new TextView(getContext());
            mNumberIndicatorTv.setId(R.id.xbanner_pointId);
            mNumberIndicatorTv.setGravity(Gravity.CENTER);
            mNumberIndicatorTv.setSingleLine(true);
            mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
            mNumberIndicatorTv.setTextColor(mTipTextColor);
            mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
            mNumberIndicatorTv.setVisibility(View.INVISIBLE);
            if (mNumberIndicatorBackground != null) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
                } else {
                    mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
                }
            }
            pointContainerRl.addView(mNumberIndicatorTv, mPointRealContainerLp);
        } else {
            mPointRealContainerLl = new LinearLayout(getContext());
            mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
            mPointRealContainerLl.setId(R.id.xbanner_pointId);
            pointContainerRl.addView(mPointRealContainerLl, mPointRealContainerLp);
        }

        /*设置指示器是否可见*/
        if (mPointRealContainerLl != null) {
            if (mPointsIsVisible) {
                mPointRealContainerLl.setVisibility(View.VISIBLE);
            } else {
                mPointRealContainerLl.setVisibility(View.GONE);
            }
        }

        /*设置提示语*/
        LayoutParams pointLp = new LayoutParams(RMP, RWC);
        pointLp.addRule(CENTER_VERTICAL);

        if (mIsShowTips) {
            mTipTv = new TextView(getContext());
            mTipTv.setGravity(Gravity.CENTER_VERTICAL);
            mTipTv.setSingleLine(true);
            if (mIsTipsMarquee) {
                mTipTv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                mTipTv.setMarqueeRepeatLimit(3);
                mTipTv.setSelected(true);
            } else {
                mTipTv.setEllipsize(TextUtils.TruncateAt.END);
            }
            mTipTv.setTextColor(mTipTextColor);
            mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
            pointContainerRl.addView(mTipTv, pointLp);
        }

        /*设置指示器布局位置*/
        if (CENTER == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
            pointLp.addRule(RelativeLayout.LEFT_OF, R.id.xbanner_pointId);
        } else if (LEFT == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            if (mTipTv != null) {
                mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
            }
            pointLp.addRule(RelativeLayout.RIGHT_OF, R.id.xbanner_pointId);
        } else if (RIGHT == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            pointLp.addRule(RelativeLayout.LEFT_OF, R.id.xbanner_pointId);
        }
        setBannerPlaceholderDrawable();
    }