本文整理汇总了Java中android.support.v7.preference.PreferenceViewHolder类的典型用法代码示例。如果您正苦于以下问题:Java PreferenceViewHolder类的具体用法?Java PreferenceViewHolder怎么用?Java PreferenceViewHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PreferenceViewHolder类属于android.support.v7.preference包,在下文中一共展示了PreferenceViewHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.itemView.setClickable(false); // disable parent click
//Loop through all the ThemeViews
for(WidgetTheme widgetTheme : WidgetTheme.values()) {
final String name = widgetTheme.name();
final int themeViewId = widgetTheme.getThemeViewId();
final int summaryRes = widgetTheme.getSummaryRes();
View button = holder.findViewById(themeViewId);
button.setClickable(true);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setSummary(summaryRes);
persistString(name);
}
});
}
}
示例2: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.itemView.setClickable(false);
for (int i = 0; i < BUTTONS.size(); i++) {
final int buttonId = BUTTONS.keyAt(i);
final String value = BUTTONS.valueAt(i);
View button = holder.findViewById(buttonId);
button.setClickable(true);
button.setOnClickListener(v -> {
mSelectedTheme = value;
if (shouldDisableDependents()) {
Preferences.Theme.disableAutoDayNight(getContext());
}
setSummary(VALUES.get(value).summary);
persistString(value);
});
}
}
示例3: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return;
}
mItemView = view.itemView;
mAnchor = view.itemView.findViewById(android.R.id.empty);
if (mAnchor == null) {
throw new IllegalStateException("SimpleMenuPreference item layout must contain" +
"a view id is android.R.id.empty to support iconSpaceReserved");
}
}
示例4: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
View view = holder.itemView;
mColorView = new View(getContext());
mColorView.setId("ID".hashCode());
int size = (int) dpToPx(32);
mColorView.setLayoutParams(new ViewGroup.LayoutParams(size, size));
ViewGroup frame = (ViewGroup) view.findViewById(android.R.id.widget_frame);
frame.setVisibility(View.VISIBLE);
addView(frame, mColorView);
if (mMaterial) {
TextView textTitle = (TextView) view.findViewById(android.R.id.title);
TextView textSummary = (TextView) view.findViewById(android.R.id.summary);
textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
textSummary.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
textTitle.setTextColor(getColor(android.R.attr.textColor));
textSummary.setTextColor(getColor(android.R.attr.textColorSecondary));
View parent = (View) textSummary.getParent().getParent();
parent.setPadding((int) dpToPx(16), 0, (int) dpToPx(16), 0);
}
}
示例5: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
// Intercept the click listener for this preference, and if the preference has an intent,
// launch the intent ourselves, so that we can catch the exception if the intent fails.
// (but only do this if the preference doesn't already have a click listener)
if (this.getOnPreferenceClickListener() == null) {
this.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference.getIntent() != null) {
try {
getContext().startActivity(preference.getIntent());
} catch (ActivityNotFoundException e) {
Toast.makeText(getContext(), getContext().getString(R.string.error_browser_not_found), Toast.LENGTH_LONG).show();
}
return true;
}
return false;
}
});
}
}
示例6: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
// We get the reference to the mSeekBar
mSeekBar = (SeekBar) holder.findViewById(R.id.size_seek_bar);
mSeekBar.setMax(mMaxValue);
mSeekBar.setOnSeekBarChangeListener(this);
mSeekBarValueTextView = (TextView) holder.findViewById(R.id.seek_bar_value);
mTitleView = (TextView) holder.findViewById(R.id.title);
mTitleView.setText(getTitle());
// This is called after the initial value is set
mSeekBar.setProgress(mProgressValue);
updateCurrentValue(mProgressValue);
}
示例7: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
colorWidget = (ImageView) holder.findViewById(R.id.color_picker_widget);
setColorOnWidget(color);
}
示例8: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
if (primary) {
((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
} else if (accent) {
((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getAccentColor().getColorRes()));
}
}
示例9: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
View colorView = holder.findViewById(R.id.color_view);
colorView.setBackgroundResource(R.drawable.shape_circle);
colorView.getBackground().setColorFilter(getSelectedColor(), PorterDuff.Mode.SRC_IN);
}
示例10: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder viewHolder) {
super.onBindViewHolder(viewHolder);
colorView = viewHolder.findViewById(R.id.color_preview);
((GradientDrawable)
((LayerDrawable) colorView.getBackground())
.findDrawableByLayerId(R.id.color))
.setColor(color);
}
示例11: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
App app = (App) getContext().getApplicationContext();
TextView user = (TextView) holder.findViewById(R.id.user_Name);
ImageView picture = (ImageView) holder.findViewById(R.id.user_Profile);
String name = app.account.getName();
if (name == null) {
name = "User";
}
user.setText(name);
Picasso.with(getContext()).load(app.account.getPictureURL()).placeholder(R.drawable.ic_placeholder).into(picture);
}
示例12: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
mColorView = holder.findViewById(com.thebluealliance.spectrum.R.id.color_preference_widget);
updateColorView();
}
示例13: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
String changedText = (String) o;
if (getText() == null || getText().compareTo(changedText) != 0) {
setChanged(true);
setSummary(changedText);
}
return true;
}
});
}
示例14: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
LinearLayout container = (LinearLayout) holder.findViewById(R.id.pref_repeating_container);
container.removeAllViews();
for(int i = 0; i < mRepeatingDays.length; i++) {
DayView dayView = new DayView(getContext(), this, i);
dayView.setText(mDayNames[i]);
dayView.setRepeating(mRepeatingDays[i]);
container.addView(dayView);
}
super.onBindViewHolder(holder);
}
示例15: onBindViewHolder
import android.support.v7.preference.PreferenceViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
setChanged(mInitiallyChecked != (boolean) o);
return true;
}
});
}