Example usage for android.widget CheckedTextView setChecked

List of usage examples for android.widget CheckedTextView setChecked

Introduction

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

Prototype

public void setChecked(boolean checked) 

Source Link

Document

Sets the checked state of this view.

Usage

From source file:com.agna.setmaster.ui.screen.condition.time.widget.DaysOfWeekView.java

private void initView(Context context) {
    inflate(context, R.layout.days_of_week_view_layout, this);
    dayViews.addAll(Arrays.asList((CheckedTextView) findViewById(R.id.monday),
            (CheckedTextView) findViewById(R.id.tuesday), (CheckedTextView) findViewById(R.id.wednesday),
            (CheckedTextView) findViewById(R.id.thursday), (CheckedTextView) findViewById(R.id.friday),
            (CheckedTextView) findViewById(R.id.saturday), (CheckedTextView) findViewById(R.id.sunday)));
    for (CheckedTextView view : dayViews) {
        view.setOnClickListener(v -> {
            CheckedTextView checkedTextView = (CheckedTextView) v;
            checkedTextView.setChecked(!checkedTextView.isChecked());
        });//from   w  w  w  . j a va  2  s . c  o m
    }
}

From source file:com.cyanogenmod.settings.otgtoggle.OtgModeChooserActivity.java

private void inflateOption(final int titleResId, final int summaryResId, int mode, int currentMode,
        LinearLayout container) {/*w  ww . ja  v  a2 s.c  om*/
    View v = mLayoutInflater.inflate(R.layout.radio_with_summary, container, false);
    CheckedTextView title = (CheckedTextView) v.findViewById(android.R.id.title);
    TextView summary = (TextView) v.findViewById(android.R.id.summary);

    title.setText(titleResId);
    title.setChecked(mode == currentMode);
    summary.setText(summaryResId);

    v.setTag(mode);
    v.setOnClickListener(this);
    container.addView(v);
}

From source file:com.nextgis.maplibui.util.TrackView.java

private void init(Context context) {
    mContext = context;/*from  w w w .  ja va2 s  .c  o m*/
    mSelectedIds = new ArrayList<>();

    int[] attrs = new int[] { R.attr.ic_action_visibility_on, R.attr.ic_action_visibility_off };
    TypedArray ta = mContext.obtainStyledAttributes(attrs);
    mVisibilityOn = ta.getDrawable(0);
    mVisibilityOff = ta.getDrawable(1);
    ta.recycle();

    setItemsCanFocus(false);
    setChoiceMode(CHOICE_MODE_MULTIPLE);

    if (context instanceof AppCompatActivity) {
        AppCompatActivity activity = (AppCompatActivity) context;
        IGISApplication application = (IGISApplication) activity.getApplication();
        mContentUriTracks = Uri
                .parse("content://" + application.getAuthority() + "/" + TrackLayer.TABLE_TRACKS);

        String[] from = new String[] { TrackLayer.FIELD_NAME, TrackLayer.FIELD_VISIBLE };
        int[] to = new int[] { R.id.tv_name, R.id.iv_visibility };
        mTrackAdapter = new TrackAdapter(context, R.layout.row_track, null, from, to,
                CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
        setAdapter(mTrackAdapter);

        activity.getSupportLoaderManager().initLoader(TRACKS_ID, null, this);
    }

    setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckedTextView name = (CheckedTextView) view.findViewById(R.id.tv_name);
            name.setChecked(!name.isChecked());

            if (name.isChecked())
                mSelectedIds.add(id + "");
            else
                mSelectedIds.remove(id + "");

            if (mCheckedChangeListener != null)
                mCheckedChangeListener.onCheckedChanged();
        }
    });
}

From source file:com.keithcassidy.finishline.LineCrossingsFragment.java

private void loadList() {
    ListView list = (ListView) getActivity().findViewById(R.id.listViewCrossings);
    TextView noneYet = (TextView) getActivity().findViewById(R.id.textViewNone);
    if (list != null && noneYet != null) {
        list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

        list.setOnItemClickListener(new OnItemClickListener() {
            @Override/*from   w  w  w .  j  a  va2s . com*/
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                getListView().setItemChecked(position, true);

                CheckedTextView c = (CheckedTextView) view.findViewById(R.id.crossing_time);
                if (c != null) {
                    c.setChecked(true);
                }
            }
        });

        ArrayList<Location> crossings = (ArrayList<Location>) dbStorage.getCrossings();
        mAdapter = new CrossingsAdapter(getActivity(), R.layout.crossing_list_item, crossings);
        list.setAdapter(mAdapter);

        if (crossings.isEmpty()) {
            list.setVisibility(ListView.INVISIBLE);
            noneYet.setVisibility(ListView.VISIBLE);
        } else {
            list.setVisibility(ListView.VISIBLE);
            noneYet.setVisibility(ListView.INVISIBLE);
        }

        list.post(new Runnable() {
            @Override
            public void run() {
                //select the last one in the list by default
                getListView().setItemChecked(getListView().getCount() - 1, true);
                getListView().setSelection(getListView().getCount() - 1);
            }
        });
    }
}

From source file:com.germainz.identiconizer.ContactsListActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    CheckedTextView checkedTextView = (CheckedTextView) v.findViewById(R.id.check);
    boolean isChecked = !checkedTextView.isChecked();
    if (isChecked)
        checkedItems.add(position);/*from  ww  w . j  a v  a  2 s .  co m*/
    else
        checkedItems.remove((Integer) position);
    checkedTextView.setChecked(isChecked);
}

From source file:com.mk4droid.IMC_Activities.Fragment_Filters.java

@Override
public void onClick(View v) {
    FiltersChangedFlag = true;//from w ww.  j a v a  2  s.  c  om

    String Tag = (String) v.getTag();
    CheckedTextView ctv = (CheckedTextView) v;
    boolean currState = ctv.isChecked();

    ctv.setChecked(!currState);
    savePreferences(Tag, !currState, "boolean");
}

From source file:com.rp.podemu.SettingsActivity.java

private void setDebugInfo() {
    String enableDebug = sharedPref.getString("enableDebug", "false");

    TextView enableDebugValue = (TextView) findViewById(R.id.enableDebugValue);
    CheckedTextView enableDebugHint = (CheckedTextView) findViewById(R.id.enableDebugHint);

    if (enableDebug.equals("true")) {
        enableDebugValue.setText("Debug Enabled");
        enableDebugHint.setChecked(true);
    } else {// ww w.j  a v  a 2 s. c  o m
        enableDebugValue.setText("Debug Disabled");
        enableDebugHint.setChecked(false);
    }

    enableDebugHint.setText(getResources().getString(R.string.enable_debug_hint)
            + " Logs will be saved to the following file: " + PodEmuLog.getLogFileName());
}

From source file:uk.org.ngo.squeezer.itemlist.dialog.AlbumViewDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlbumListActivity activity = (AlbumListActivity) getActivity();

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(activity.getServerString(ServerString.ALBUM_DISPLAY_OPTIONS));
    builder.setAdapter(new BaseAdapter() {
        @Override/* w  ww .  j a  v a2s . c o  m*/
        public boolean areAllItemsEnabled() {
            return false;
        }

        @Override
        public boolean isEnabled(int position) {
            return (position != POSITION_SORT_LABEL);
        }

        @Override
        public int getCount() {
            return AlbumListLayout.values().length + 1 + AlbumsSortOrder.values().length;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (position < POSITION_SORT_LABEL) {
                CheckedTextView textView = (CheckedTextView) activity.getLayoutInflater()
                        .inflate(android.R.layout.select_dialog_singlechoice, parent, false);
                AlbumListLayout listLayout = AlbumListLayout.values()[position];
                textView.setCompoundDrawablesWithIntrinsicBounds(listLayout.icon, 0, 0, 0);
                textView.setText(activity.getServerString(listLayout.serverString));
                textView.setChecked(listLayout == activity.getListLayout());
                return textView;
            } else if (position > POSITION_SORT_LABEL) {
                CheckedTextView textView = (CheckedTextView) activity.getLayoutInflater()
                        .inflate(android.R.layout.select_dialog_singlechoice, parent, false);
                position -= POSITION_SORT_START;
                AlbumsSortOrder sortOrder = AlbumsSortOrder.values()[position];
                textView.setText(activity.getServerString(sortOrder.serverString));
                textView.setChecked(sortOrder == activity.getSortOrder());
                return textView;
            }

            TextView textView = new TextView(activity, null, android.R.attr.listSeparatorTextViewStyle);
            textView.setText(
                    getString(R.string.choose_sort_order, activity.getItemAdapter().getQuantityString(2)));
            return textView;
        }
    }, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int position) {
            if (position < POSITION_SORT_LABEL) {
                activity.setListLayout(AlbumListLayout.values()[position]);
                dialog.dismiss();
            } else if (position > POSITION_SORT_LABEL) {
                position -= POSITION_SORT_START;
                activity.setSortOrder(AlbumsSortOrder.values()[position]);
                dialog.dismiss();
            }
        }
    });
    return builder.create();
}

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

/**
 * Set the current page of this TabPageIndicator.
 * @param position The position of current page.
 *//*from www.  j  av a  2s. c o  m*/
public void setCurrentItem(int position) {
    if (mSelectedPosition != position) {
        CheckedTextView tv = getTabView(mSelectedPosition);
        if (tv != null)
            tv.setChecked(false);
    }

    mSelectedPosition = position;
    CheckedTextView tv = getTabView(mSelectedPosition);
    if (tv != null)
        tv.setChecked(true);

    animateToTab(position);
}

From source file:itkach.aard2.SettingsListAdapter.java

private View getFavRandomSwitchView(View convertView, ViewGroup parent) {
    View view;/*from w  ww  .j  av  a 2 s  . c  o m*/
    LayoutInflater inflater = (LayoutInflater) parent.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Application app = (Application) context.getApplication();
    if (convertView != null) {
        view = convertView;
    } else {
        view = inflater.inflate(R.layout.settings_fav_random_search, parent, false);
        final CheckedTextView toggle = (CheckedTextView) view.findViewById(R.id.setting_fav_random_search);
        toggle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean currentValue = app.isOnlyFavDictsForRandomLookup();
                boolean newValue = !currentValue;
                app.setOnlyFavDictsForRandomLookup(newValue);
                toggle.setChecked(newValue);
            }
        });
    }
    boolean currentValue = app.isOnlyFavDictsForRandomLookup();
    CheckedTextView toggle = (CheckedTextView) view.findViewById(R.id.setting_fav_random_search);
    toggle.setChecked(currentValue);
    return view;
}