Example usage for android.widget CheckedTextView setCheckMarkDrawable

List of usage examples for android.widget CheckedTextView setCheckMarkDrawable

Introduction

In this page you can find the example usage for android.widget CheckedTextView setCheckMarkDrawable.

Prototype

public void setCheckMarkDrawable(@Nullable Drawable d) 

Source Link

Document

Set the check mark to the specified drawable.

Usage

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabPageIndicator.java

private void addTemporaryTab() {
    for (int i = 0; i < 3; i++) {
        CharSequence title = null;
        if (i == 0)
            title = "TAB ONE";
        else if (i == 1)
            title = "TAB TWO";
        else if (i == 2)
            title = "TAB THREE";

        CheckedTextView tv = new CheckedTextView(getContext());
        tv.setCheckMarkDrawable(null);
        tv.setText(title);/*from w w  w  .j  a  v  a2  s  . co m*/
        tv.setGravity(Gravity.CENTER);
        tv.setTextAppearance(getContext(), mTextAppearance);
        tv.setSingleLine(true);
        tv.setEllipsize(TruncateAt.END);
        tv.setTag(i);
        tv.setChecked(i == 0);
        if (mMode == MODE_SCROLL) {
            tv.setPadding(mTabPadding, 0, mTabPadding, 0);
            mTabContainer.addView(tv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
        } else if (mMode == MODE_FIXED) {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,
                    LinearLayout.LayoutParams.MATCH_PARENT);
            params.weight = 1f;
            mTabContainer.addView(tv, params);
        }
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabPageIndicator.java

private void notifyDataSetChanged() {
    mTabContainer.removeAllViews();/*from   w  ww  . j a v a  2s . co m*/

    PagerAdapter adapter = mViewPager.getAdapter();
    final int count = adapter.getCount();

    if (mSelectedPosition > count)
        mSelectedPosition = count - 1;

    for (int i = 0; i < count; i++) {
        CharSequence title = adapter.getPageTitle(i);
        if (title == null)
            title = "NULL";

        CheckedTextView tv = new CheckedTextView(getContext());
        tv.setCheckMarkDrawable(null);
        tv.setText(title);
        tv.setGravity(Gravity.CENTER);
        tv.setTextAppearance(getContext(), mTextAppearance);
        if (mTabSingleLine)
            tv.setSingleLine(true);
        else {
            tv.setSingleLine(false);
            tv.setMaxLines(2);
        }
        tv.setEllipsize(TruncateAt.END);
        tv.setOnClickListener(this);
        tv.setTag(i);
        if (mTabRippleStyle > 0)
            ViewUtil.setBackground(tv, new RippleDrawable.Builder(getContext(), mTabRippleStyle).build());

        tv.setPadding(mTabPadding, 0, mTabPadding, 0);
        mTabContainer.addView(tv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
    }

    setCurrentItem(mSelectedPosition);
    requestLayout();
}

From source file:com.simplealertdialog.SimpleAlertDialog.java

public void setSingleChoiceItems(final CharSequence[] items, final int checkedItem,
        final AdapterView.OnItemClickListener listener) {
    if (items == null) {
        return;//from   w w w .  j ava 2s. c om
    }
    mAdapter = new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_list_item_single_choice,
            items) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            if (view != null) {
                CheckedTextView c = (CheckedTextView) view.findViewById(android.R.id.text1);
                if (mListChoiceIndicatorSingle != 0) {
                    c.setCheckMarkDrawable(mListChoiceIndicatorSingle);
                }
                if (mListItemTextStyle != 0) {
                    c.setTextAppearance(getContext(), mListItemTextStyle);
                }
                setBackground(c, mListSelectorBackground);
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
                    Resources res = getContext().getResources();
                    c.setPadding(res.getDimensionPixelSize(R.dimen.sad__simple_list_item_padding_left), 0,
                            res.getDimensionPixelSize(R.dimen.sad__simple_list_item_padding_right), 0);
                }
            }
            return view;
        }
    };
    mSingleChoice = true;
    mCheckedItem = checkedItem;
    mListItemListener = listener;
}