Java Code Examples for android.widget.CheckedTextView#setText()

The following examples show how to use android.widget.CheckedTextView#setText() . 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
Source File: HideFoldersActivity.java    From LrcJaeger with Apache License 2.0 8 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.folder_item, parent, false);
    }

    String folder = getItem(position);

    CheckedTextView tv = (CheckedTextView) convertView.findViewById(R.id.cb_folder);
    tv.setText(folder);
    if (mHiddenFolders.contains(folder.hashCode())) {
        // this folder was set to be hidden
        tv.setChecked(false);
        tv.setTextColor(Color.LTGRAY);
    } else {
        // set default status
        tv.setChecked(true);
        tv.setTextColor(Color.BLACK);
    }

    return convertView;
}
 
Example 2
Source File: ImageListPreference.java    From Identiconizer with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    View row = inflater.inflate(R.layout.image_list_item, parent, false);

    ImageView imageView = row.findViewById(R.id.image);
    imageView.setImageResource(resourceIds[position]);

    CheckedTextView checkedTextView = row.findViewById(R.id.check);

    checkedTextView.setText(getItem(position));
    checkedTextView.setCheckMarkDrawable(Resources.getSystem().getDrawable(mRadioDrawableId));

    if (position == index) {
        checkedTextView.setChecked(true);
    }

    return row;
}
 
Example 3
Source File: EventSelectionFragment.java    From attendee-checkin with Apache License 2.0 6 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
    CheckedTextView textView = (CheckedTextView) view;
    textView.setText(cursor.getString(cursor.getColumnIndexOrThrow(Table.Event.NAME)));
    String eventId = cursor.getString(cursor.getColumnIndexOrThrow(Table.Event.ID));
    view.setTag(eventId);
    if (textView.getPaddingLeft() > 0) { // on Dropdown
        long endTime = cursor.getLong(cursor.getColumnIndexOrThrow(Table.Event.END_TIME));
        if (TextUtils.equals(mCurrentEventId, eventId)) {
            textView.setTextColor(mTextColorCurrent);
        } else if (endTime * 1000 < System.currentTimeMillis()) { // Past
            textView.setTextColor(mTextColorPast);
        } else {
            textView.setTextColor(mTextColorDefault);
        }
    } else { // on Toolbar
        textView.setTextColor(mTextColorInverse);
    }
}
 
Example 4
Source File: TrackView.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {

    final Integer id = cursor.getInt(0);
    final ImageView visibility = (ImageView) view.findViewById(R.id.iv_visibility);
    visibility.setImageDrawable(cursor.getInt(2) != 0 ? mVisibilityOn : mVisibilityOff);
    visibility.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean isVisible = visibility.getDrawable().equals(mVisibilityOn);
            updateRecord(id, !isVisible);
        }
    });

    CheckedTextView name = (CheckedTextView) view.findViewById(R.id.tv_name);
    name.setChecked(mSelectedIds.contains(id + ""));
    name.setText(cursor.getString(1));
}
 
Example 5
Source File: MainActivity.java    From Phlux with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.thread_demo).setOnClickListener(v -> startActivity(new Intent(this, DemoActivity.class)));

    check1 = (CheckedTextView) findViewById(R.id.check1);
    check2 = (CheckedTextView) findViewById(R.id.check2);

    check1.setText(MainState.NAME_1);
    check2.setText(MainState.NAME_2);

    check1.setOnClickListener(v -> switchTo(MainState.NAME_1));
    check2.setOnClickListener(v -> switchTo(MainState.NAME_2));

    ListView listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(adapter = new ArrayAdapter<>(this, R.layout.item));
}
 
Example 6
Source File: SettingsActivity.java    From PodEmu with GNU General Public License v3.0 6 votes vote down vote up
private void setDebugInfo()
{

    PodEmuLog.checkPermissions();
    CheckedTextView enableDebugHint = (CheckedTextView) findViewById(R.id.enableDebugHint);

    String enableDebug = sharedPref.getString("enableDebug", "false");
    //TextView enableDebugValue = (TextView) findViewById(R.id.enableDebugValue);

    if( enableDebug.equals("true") )
    {
        //enableDebugValue.setText("Debug Enabled");
        enableDebugHint.setChecked(true);
    }
    else
    {
        //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());
}
 
Example 7
Source File: ClearDataPreferenceActivity.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public @NonNull View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
	View view = super.getView(position, convertView, parent);

	String name = values.get(position);
	CheckedTextView checkedView = (CheckedTextView) view.findViewById(R.id.checkedTextView);
	checkedView.setText(name);

	return view;
}
 
Example 8
Source File: IconListPreference.java    From EdXposedManager with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    @SuppressLint("ViewHolder") View view = inflater.inflate(R.layout.icon_preference_item, parent, false);
    CheckedTextView textView = view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == mSelectedIndex);

    ImageView imageView = view.findViewById(R.id.icon);
    imageView.setImageDrawable(mImageDrawables.get(position));
    return view;
}
 
Example 9
Source File: IconListPreference.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
@SuppressLint("ViewHolder")
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    View view = inflater.inflate(R.layout.item_icon_preference, parent, false);
    CheckedTextView textView = view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == mSelectedIndex);

    ImageView imageView = view.findViewById(R.id.icon);
    imageView.setImageDrawable(mImageDrawables.get(position));
    return view;
}
 
Example 10
Source File: FontPreference.java    From simpletask-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View getView( int position, View convertView, ViewGroup parent )
{
    View view = convertView;

    // This function may be called in two cases: a new view needs to be created,
    // or an existing view needs to be reused
    if ( view == null )
    {
        // Since we're using the system list for the layout, use the system inflater
        final LayoutInflater inflater = (LayoutInflater)
                getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );

        // And inflate the view android.R.layout.select_dialog_singlechoice
        // Why? See com.android.internal.app.AlertController method createListView()
        view = inflater.inflate( android.R.layout.select_dialog_singlechoice, parent, false);
    }

    if ( view != null )
    {
        // Find the text view from our interface
        CheckedTextView tv = view.findViewById( android.R.id.text1 );

        // Replace the string with the current font name using our typeface
        String path = m_fontPaths.get( position );
        Typeface tface = Typeface.DEFAULT;
        if (!"".equals(path)) {
            tface = Typeface.createFromFile(m_fontPaths.get(position));
        }
        tv.setTypeface( tface );

        // If you want to make the selected item having different foreground or background color,
        // be aware of themes. In some of them your foreground color may be the background color.
        // So we don't mess with anything here and just add the extra stars to have the selected
        // font to stand out.
        tv.setText( m_fontNames.get( position ) );
    }

    return view;
}
 
Example 11
Source File: StayAwakeTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@SuppressLint("ViewHolder")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    CheckedTextView label = (CheckedTextView) inflater.inflate(
            android.R.layout.simple_list_item_single_choice, parent, false);
    ScreenTimeout st = getItem(position);
    label.setText(mGbContext.getString(st.mLabelResId));
    return label;
}
 
Example 12
Source File: FieldSelector.java    From android-places-demos with Apache License 2.0 5 votes vote down vote up
private static void updateView(View view, State state) {
  if (view instanceof CheckedTextView) {
    CheckedTextView checkedTextView = (CheckedTextView) view;
    checkedTextView.setText(state.field.toString());
    checkedTextView.setChecked(state.checked);
  }
}
 
Example 13
Source File: FieldSelector.java    From android-places-demos with Apache License 2.0 5 votes vote down vote up
private static void updateView(View view, State state) {
  if (view instanceof CheckedTextView) {
    CheckedTextView checkedTextView = (CheckedTextView) view;
    checkedTextView.setText(state.field.toString());
    checkedTextView.setChecked(state.checked);
  }
}
 
Example 14
Source File: PostShare.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
	if (convertView == null)
	{
		convertView = inflater.inflate(android.R.layout.simple_spinner_dropdown_item, parent, false);
	}

	CheckedTextView ct = (CheckedTextView) convertView.findViewById(android.R.id.text1);
	ct.setText(getItem(position).getName());

	return convertView;
}
 
Example 15
Source File: PostAlbums.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
	if (convertView == null)
	{
		convertView = inflater.inflate(android.R.layout.simple_spinner_dropdown_item, parent, false);
	}
	
	CheckedTextView ct = (CheckedTextView) convertView.findViewById(android.R.id.text1);
	ct.setText(getItem(position).getName());

	return convertView;
}
 
Example 16
Source File: IconListPreference.java    From Toutiao with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
@SuppressLint("ViewHolder")
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = ((BaseActivity) getContext()).getLayoutInflater();
    View view = inflater.inflate(R.layout.item_icon_listpreference, parent, false);

    CheckedTextView textView = view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == selectedIndex);

    ImageView imageView = view.findViewById(R.id.icon);
    imageView.setImageDrawable(list.get(position));
    return view;
}
 
Example 17
Source File: ThemeListPreference.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public View getView(final int position, View convertView, ViewGroup parent) {
    View row = convertView;

    if (row == null) {
        row = mInflater.inflate(android.R.layout.simple_list_item_single_choice, parent, false);
    }
    CheckedTextView tv = (CheckedTextView) row.findViewById(android.R.id.text1);
    tv.setText(getItem(position).toString());
    tv.setChecked(mEntryIndex == position);
    tv.setTextColor(Color.parseColor(colors[position]));
    return row;
}
 
Example 18
Source File: TrackSelectionHelper.java    From ExoPlayer-Offline with Apache License 2.0 4 votes vote down vote up
@SuppressLint("InflateParams")
private View buildView(Context context) {
  LayoutInflater inflater = LayoutInflater.from(context);
  View view = inflater.inflate(R.layout.track_selection_dialog, null);
  ViewGroup root = (ViewGroup) view.findViewById(R.id.root);

  TypedArray attributeArray = context.getTheme().obtainStyledAttributes(
      new int[] {android.R.attr.selectableItemBackground});
  int selectableItemBackgroundResourceId = attributeArray.getResourceId(0, 0);
  attributeArray.recycle();

  // View for disabling the renderer.
  disableView = (CheckedTextView) inflater.inflate(
      android.R.layout.simple_list_item_single_choice, root, false);
  disableView.setBackgroundResource(selectableItemBackgroundResourceId);
  disableView.setText(R.string.selection_disabled);
  disableView.setFocusable(true);
  disableView.setOnClickListener(this);
  root.addView(disableView);

  // View for clearing the override to allow the selector to use its default selection logic.
  defaultView = (CheckedTextView) inflater.inflate(
      android.R.layout.simple_list_item_single_choice, root, false);
  defaultView.setBackgroundResource(selectableItemBackgroundResourceId);
  defaultView.setText(R.string.selection_default);
  defaultView.setFocusable(true);
  defaultView.setOnClickListener(this);
  root.addView(inflater.inflate(R.layout.list_divider, root, false));
  root.addView(defaultView);

  // Per-track views.
  boolean haveSupportedTracks = false;
  boolean haveAdaptiveTracks = false;
  trackViews = new CheckedTextView[trackGroups.length][];
  for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
    TrackGroup group = trackGroups.get(groupIndex);
    boolean groupIsAdaptive = trackGroupsAdaptive[groupIndex];
    haveAdaptiveTracks |= groupIsAdaptive;
    trackViews[groupIndex] = new CheckedTextView[group.length];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      if (trackIndex == 0) {
        root.addView(inflater.inflate(R.layout.list_divider, root, false));
      }
      int trackViewLayoutId = groupIsAdaptive ? android.R.layout.simple_list_item_multiple_choice
          : android.R.layout.simple_list_item_single_choice;
      CheckedTextView trackView = (CheckedTextView) inflater.inflate(
          trackViewLayoutId, root, false);
      trackView.setBackgroundResource(selectableItemBackgroundResourceId);
      trackView.setText(buildTrackName(group.getFormat(trackIndex)));
      if (trackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex)
          == RendererCapabilities.FORMAT_HANDLED) {
        trackView.setFocusable(true);
        trackView.setTag(Pair.create(groupIndex, trackIndex));
        trackView.setOnClickListener(this);
        haveSupportedTracks = true;
      } else {
        trackView.setFocusable(false);
        trackView.setEnabled(false);
      }
      trackViews[groupIndex][trackIndex] = trackView;
      root.addView(trackView);
    }
  }

  if (!haveSupportedTracks) {
    // Indicate that the default selection will be nothing.
    defaultView.setText(R.string.selection_default_none);
  } else if (haveAdaptiveTracks) {
    // View for using random adaptation.
    enableRandomAdaptationView = (CheckedTextView) inflater.inflate(
        android.R.layout.simple_list_item_multiple_choice, root, false);
    enableRandomAdaptationView.setBackgroundResource(selectableItemBackgroundResourceId);
    enableRandomAdaptationView.setText(R.string.enable_random_adaptation);
    enableRandomAdaptationView.setOnClickListener(this);
    root.addView(inflater.inflate(R.layout.list_divider, root, false));
    root.addView(enableRandomAdaptationView);
  }

  updateViews();
  return view;
}
 
Example 19
Source File: AuthPageAty.java    From Huochexing12306 with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = View.inflate(context, R.layout.auth_page_item, null);
	}

	int count = getCount();
	View llItem = convertView.findViewById(R.id.llItem);
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10);
	if (count == 1) {
		llItem.setBackgroundResource(R.drawable.list_item_single_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, dp_10, dp_10, dp_10);
	}
	else if (position == 0) {
		llItem.setBackgroundResource(R.drawable.list_item_first_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, dp_10, dp_10, 0);
	}
	else if (position == count - 1) {
		llItem.setBackgroundResource(R.drawable.list_item_last_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, 0, dp_10, dp_10);
	}
	else {
		llItem.setBackgroundResource(R.drawable.list_item_middle_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, 0, dp_10, 0);
	}

	Platform plat = getItem(position);
	ImageView ivLogo = (ImageView) convertView.findViewById(R.id.ivLogo);
	Bitmap logo = getIcon(plat);
	if (logo != null && !logo.isRecycled()) {
		ivLogo.setImageBitmap(logo);
	}
	CheckedTextView ctvName = (CheckedTextView) convertView.findViewById(R.id.ctvName);
	ctvName.setChecked(plat.isValid());
	if (plat.isValid()) {
		String userName = plat.getDb().get("nickname");
		if (userName == null || userName.length() <= 0 || "null".equals(userName)) {
			userName = getName(plat);
		}
		ctvName.setText(userName);
	} else {
		ctvName.setText(R.string.not_yet_authorized);
	}
	return convertView;
}
 
Example 20
Source File: AppCompatTimePickerDelegate.java    From AppCompat-Extension-Library with Apache License 2.0 4 votes vote down vote up
public AppCompatTimePickerDelegate(AppCompatTimePicker delegator, Context context, AttributeSet attrs,
                                   int defStyleAttr, int defStyleRes) {
    super(delegator, context);

    // process style attributes
    final TypedArray a = mContext.obtainStyledAttributes(attrs,
            R.styleable.TimePickerDialog, defStyleAttr, defStyleRes);
    final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    final Resources res = mContext.getResources();

    mSelectHours = res.getString(R.string.select_hours);
    mSelectMinutes = res.getString(R.string.select_minutes);

    String[] amPmStrings = getAmPmStrings(context);
    mAmText = amPmStrings[0];
    mPmText = amPmStrings[1];

    final View mainView = inflater.inflate(R.layout.time_picker_material, delegator);

    mHeaderView = mainView.findViewById(R.id.time_header);

    // Set up hour/minute labels.
    mHourView = (TextView) mainView.findViewById(R.id.hours);
    mHourView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mHourView,
            new ClickActionDelegate(context, R.string.select_hours));
    mSeparatorView = (TextView) mainView.findViewById(R.id.separator);
    mMinuteView = (TextView) mainView.findViewById(R.id.minutes);
    mMinuteView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mMinuteView,
            new ClickActionDelegate(context, R.string.select_minutes));

    // Now that we have text appearances out of the way, make sure the hour
    // and minute views are correctly sized.
    mHourView.setMinWidth(computeStableWidth(mHourView, 24));
    mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60));

    // Set up AM/PM labels.
    mAmPmLayout = mainView.findViewById(R.id.ampm_layout);
    mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label);
    mAmLabel.setText(obtainVerbatim(amPmStrings[0]));
    mAmLabel.setOnClickListener(mClickListener);
    mPmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.pm_label);
    mPmLabel.setText(obtainVerbatim(amPmStrings[1]));
    mPmLabel.setOnClickListener(mClickListener);


    // Set up header text color, if available.
    ColorStateList headerTextColor;
    if (a.hasValue(R.styleable.TimePickerDialog_headerTextColor)) {
        headerTextColor = a.getColorStateList(R.styleable.DatePickerDialog_headerTextColor);
    } else {
        headerTextColor = PickerThemeUtils.getHeaderTextColorStateList(mContext);
    }
    mHourView.setTextColor(headerTextColor);
    mSeparatorView.setTextColor(headerTextColor);
    mMinuteView.setTextColor(headerTextColor);
    mAmLabel.setTextColor(headerTextColor);
    mPmLabel.setTextColor(headerTextColor);

    // Set up header background, if available.
    ViewCompatUtils.setBackground(mHeaderView, PickerThemeUtils.getHeaderBackground(mContext,
            a.getColor(R.styleable.DatePickerDialog_headerBackground,
                    ThemeUtils.getThemeAttrColor(mContext, R.attr.colorAccent))));

    a.recycle();

    mRadialTimePickerView = (RadialTimePickerView) mainView.findViewById(
            R.id.radial_picker);

    setupListeners();

    mAllowAutoAdvance = true;

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();

    // Initialize with current time
    final Calendar calendar = Calendar.getInstance(mCurrentLocale);
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);
    initialize(currentHour, currentMinute, false /* 12h */, HOUR_INDEX);
}