本文整理汇总了Java中android.view.View.setContentDescription方法的典型用法代码示例。如果您正苦于以下问题:Java View.setContentDescription方法的具体用法?Java View.setContentDescription怎么用?Java View.setContentDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setContentDescription方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureCallButton
import android.view.View; //导入方法依赖的package包/类
/** Configures the call button area using the given entry. */
private void configureCallButton(String callText, CharSequence nbrLabel, CharSequence number) {
View convertView = getView().findViewById(R.id.call_and_sms);
convertView.setVisibility(TextUtils.isEmpty(number) ? View.GONE : View.VISIBLE);
TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text);
View mainAction = convertView.findViewById(R.id.call_and_sms_main_action);
mainAction.setOnClickListener(mPrimaryActionListener);
mainAction.setContentDescription(callText);
if(TextUtils.isEmpty(number)) {
number = "";
}
mainAction.setTag(SipUri.getCanonicalSipContact(number.toString(), false));
text.setText(callText);
TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
if (TextUtils.isEmpty(nbrLabel)) {
label.setVisibility(View.GONE);
} else {
label.setText(nbrLabel);
label.setVisibility(View.VISIBLE);
}
}
示例2: setSwatchDescription
import android.view.View; //导入方法依赖的package包/类
/**
* Add a content description to the specified swatch view. Because the colors get added in a
* snaking form, every other row will need to compensate for the fact that the colors are added
* in an opposite direction from their left->right/top->bottom order, which is how the system
* will arrange them for accessibility purposes.
*/
private void setSwatchDescription(int rowNumber, int index, int rowElements, boolean selected,
View swatch, String[] contentDescriptions) {
String description;
if (contentDescriptions != null && contentDescriptions.length > index) {
description = contentDescriptions[index];
} else {
int accessibilityIndex;
if (rowNumber % 2 == 0) {
// We're in a regular-ordered row
accessibilityIndex = index + 1;
} else {
// We're in a backwards-ordered row.
int rowMax = ((rowNumber + 1) * mNumColumns);
accessibilityIndex = rowMax - rowElements;
}
if (selected) {
description = String.format(mDescriptionSelected, accessibilityIndex);
} else {
description = String.format(mDescription, accessibilityIndex);
}
}
swatch.setContentDescription(description);
}
示例3: setAccessibilityIgnore
import android.view.View; //导入方法依赖的package包/类
public static void setAccessibilityIgnore(View view) {
view.setClickable(false);
view.setFocusable(false);
view.setContentDescription("");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
}
示例4: setAccessiblityIgnore
import android.view.View; //导入方法依赖的package包/类
public static void setAccessiblityIgnore(View view) {
view.setClickable(false);
view.setFocusable(false);
view.setContentDescription("");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
}
示例5: onBindView
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onBindView(View view) {
super.onBindView(view);
mImageView = (ImageView) view.findViewById(R.id.expando);
if (mDrawable != null) mImageView.setImageDrawable(mDrawable);
// For accessibility, read out the whole title and whether the group is collapsed/expanded.
String description = getTitle() + getContext().getResources().getString(mExpanded
? R.string.accessibility_expanded_group
: R.string.accessibility_collapsed_group);
view.setContentDescription(description);
}
示例6: onBindView
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onBindView(final View view) {
super.onBindView(view);
// On pre-L devices, PreferenceCategoryWithButtonStyle is reused for PreferenceCategory,
// which needs a top padding of 16dp; we don't want this top padding for
// PreferenceCategoryWithButton views.
view.setPadding(view.getPaddingLeft(), 0, view.getPaddingRight(), view.getPaddingBottom());
View button = view.findViewById(android.R.id.icon);
button.setOnClickListener(this);
if (!TextUtils.isEmpty(mContentDescription)) {
button.setContentDescription(mContentDescription);
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:PreferenceCategoryWithButton.java
示例7: onCreateView
import android.view.View; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = new View(getContext());
view.setContentDescription("First Fragment");
return view;
}
示例8: onCreateView
import android.view.View; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = new View(getContext());
view.setContentDescription("Second Fragment");
return view;
}
示例9: onCreateViewHolder
import android.view.View; //导入方法依赖的package包/类
@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view;
switch (viewType) {
case SampleAppConstants.TITLE:
// Programmatically set the text of the title here.
view = mInflater.inflate(R.layout.title_layout, parent, false);
TextView titleView = view.findViewById(R.id.title_text);
titleView.setText(R.string.a_long_list);
break;
case SampleAppConstants.SWITCH:
// Reference the switch widget's text and view.
view = mInflater.inflate(R.layout.long_list_switch_widget_layout, parent, false);
TextView switchText = view.findViewById(R.id.switch_text);
switchText.setText(R.string.bottom_action_drawer);
mSwitchWidget = view.findViewById(R.id.switch_widget);
view.setContentDescription(
mContext.getResources()
.getString(
R.string.switch_bottom_action_drawer,
getSwitchToggleString(mSwitchWidget.isChecked())));
// Set the OnClickListener (Observer pattern used here).
view.setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
mSwitchWidget.setChecked(!(mSwitchWidget.isChecked()));
if (mSwitchChangeListener != null) {
mSwitchChangeListener.onChange(mSwitchWidget.isChecked());
}
view.setContentDescription(
mContext.getResources()
.getString(
R.string.switch_bottom_action_drawer,
getSwitchToggleString(
mSwitchWidget.isChecked())));
}
});
break;
case SampleAppConstants.HEADER_FOOTER:
view = mInflater.inflate(R.layout.header_footer_layout, parent, false);
break;
case SampleAppConstants.PROGRESS_BAR:
view = mInflater.inflate(R.layout.progress_bar_layout, parent, false);
break;
case SampleAppConstants.NORMAL:
view = mInflater.inflate(R.layout.shifted_app_item_layout, parent, false);
break;
default:
view = mInflater.inflate(R.layout.shifted_app_item_layout, parent, false);
break;
}
return new Holder(view);
}
示例10: onBind
import android.view.View; //导入方法依赖的package包/类
@Override
public void onBind(View view, Object o) {
view.setContentDescription(TestOnBind.class.getSimpleName());
}
示例11: setButtonContentDescription
import android.view.View; //导入方法依赖的package包/类
private void setButtonContentDescription(View v, int stringResouce) {
v.setContentDescription(
getResources().getString(R.string.accessibility_search_activity_add_to, // Format string
getResources().getString(stringResouce))
);
}
示例12: setAriaLabel
import android.view.View; //导入方法依赖的package包/类
protected void setAriaLabel(String label) {
View host = getHostView();
if(host != null){
host.setContentDescription(label);
}
}
示例13: bindCollectionItemView
import android.view.View; //导入方法依赖的package包/类
@Override
public void bindCollectionItemView(Context context, View view, int groupId,
int indexInGroup, int dataIndex, Object tag) {
if (GROUP_ID_KEYNOTE_STREAM_CARD == groupId ||
GROUP_ID_MESSAGE_CARDS == groupId) {
// These two group id types don't have child views.
populateSubItemInfo(context, view, groupId, tag);
// Set the object's data into the view's tag so that the click listener on the view can
// extract it and use the data to handle a click.
View clickableView = view.findViewById(R.id.explore_io_clickable_item);
if (clickableView != null) {
clickableView.setTag(tag);
}
} else {
// These group ids have children who are child items.
ViewGroup viewWithChildrenSubItems = (ViewGroup)(view.findViewById(
R.id.explore_io_card_container_contents));
ItemGroup itemGroup = (ItemGroup) tag;
// Set Header tag and title.
viewWithChildrenSubItems.getChildAt(0).setTag(tag);
TextView titleTextView = ((TextView) view.findViewById(android.R.id.title));
View headerView = view.findViewById(R.id.explore_io_card_header_layout);
if (headerView != null) {
headerView.setContentDescription(
getString(R.string.more_items_button_desc_with_label_a11y,
itemGroup.getTitle()));
}
// Set the tag on the moreButton so it can be accessed by the click listener.
View moreButton = view.findViewById(android.R.id.button1);
if (moreButton != null) {
moreButton.setTag(tag);
}
if (titleTextView != null) {
titleTextView.setText(itemGroup.getTitle());
}
// Skipping first child b/c it is a header view.
for (int viewChildIndex = 1; viewChildIndex < viewWithChildrenSubItems.getChildCount(); viewChildIndex++) {
View childView = viewWithChildrenSubItems.getChildAt(viewChildIndex);
int sessionIndex = viewChildIndex - 1;
int sessionSize = itemGroup.getSessions().size();
if (childView != null && sessionIndex < sessionSize) {
childView.setVisibility(View.VISIBLE);
SessionData sessionData = itemGroup.getSessions().get(sessionIndex);
childView.setTag(sessionData);
populateSubItemInfo(context, childView, groupId, sessionData);
} else if (childView != null) {
childView.setVisibility(View.GONE);
}
}
}
}
示例14: trySetContentDescription
import android.view.View; //导入方法依赖的package包/类
private void trySetContentDescription(View root, int viewId, int contDescResId) {
View target = root.findViewById(viewId);
if (target != null) {
target.setContentDescription(mContext.getString(contDescResId));
}
}