本文整理了Java中android.view.View.getContentDescription()
方法的一些代码示例,展示了View.getContentDescription()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。View.getContentDescription()
方法的具体详情如下:
包路径:android.view.View
类名称:View
方法名:getContentDescription
暂无
代码示例来源:origin: facebook/litho
@Override
public String apply(@Nullable View input) {
if (input == null) {
return "Provided view was null";
}
if (input.getContentDescription() == null) {
return String.format(
"No content description found, view is %s",
getVisibilityString(input.getVisibility()));
}
return String.format(
"Found content description: \"%s\", view is %s",
input.getContentDescription(), getVisibilityString(input.getVisibility()));
}
};
代码示例来源:origin: facebook/litho
@Override
public boolean apply(final View input) {
if (input instanceof ComponentHost) {
final List<CharSequence> contentDescriptions =
((ComponentHost) input).getContentDescriptions();
return contentDescriptions.contains(contentDescription);
}
return contentDescription.equals(input.getContentDescription());
}
};
代码示例来源:origin: stackoverflow.com
static void findViewsWithText(List<View> outViews, ViewGroup parent, String targetDescription) {
if (parent == null || TextUtils.isEmpty(targetDescription)) {
return;
}
final int count = parent.getChildCount();
for (int i = 0; i < count; i++) {
final View child = parent.getChildAt(i);
final CharSequence desc = child.getContentDescription();
if (!TextUtils.isEmpty(desc) && targetDescription.equals(desc.toString())) {
outViews.add(child);
} else if (child instanceof ViewGroup && child.getVisibility() == View.VISIBLE) {
findViewsWithText(outViews, (ViewGroup) child, targetDescription);
}
}
}
代码示例来源:origin: square/assertj-android
public S hasContentDescription(CharSequence contentDescription) {
isNotNull();
CharSequence actualContentDescription = actual.getContentDescription();
assertThat(actualContentDescription) //
.overridingErrorMessage("Expected content description <%s> but was <%s>",
contentDescription, actualContentDescription) //
.isEqualTo(contentDescription);
return myself;
}
代码示例来源:origin: facebook/facebook-android-sdk
public static JSONObject setBasicInfoOfView(View view, JSONObject json) {
try {
String text = getTextOfView(view);
String hint = getHintOfView(view);
Object tag = view.getTag();
CharSequence description = view.getContentDescription();
json.put(CLASS_NAME_KEY, view.getClass().getCanonicalName());
json.put(CLASS_TYPE_BITMASK_KEY, getClassTypeBitmask(view));
json.put(ID_KEY, view.getId());
if (!SensitiveUserDataUtils.isSensitiveUserData(view)) {
json.put(TEXT_KEY, text);
} else {
json.put(TEXT_KEY, "");
json.put(IS_USER_INPUT_KEY, true);
}
json.put(HINT_KEY, hint);
if (tag != null) {
json.put(TAG_KEY, tag.toString());
}
if (description != null) {
json.put(DESC_KEY, description.toString());
}
JSONObject dimension = getDimensionOfView(view);
json.put(DIMENSION_KEY, dimension);
} catch (JSONException e) {
Utility.logd(TAG, e);
}
return json;
}
代码示例来源:origin: facebook/facebook-android-sdk
& MatchBitmaskType.DESCRIPTION.getValue()) > 0) {
String pathDesc = pathElement.description;
String targetDesc = targetView.getContentDescription() == null ? "" :
String.valueOf(targetView.getContentDescription());
if (!pathDesc.equals(targetDesc)) {
return false;
代码示例来源:origin: robolectric/robolectric
@Test
public void testContentDescriptionIsSet() throws Exception {
View mediaView = inflate(layout.main);
assertThat(mediaView.findViewById(R.id.time).getContentDescription().toString())
.isEqualTo("Howdy");
}
代码示例来源:origin: heinrichreimer/material-intro
@Override
public boolean onLongClick(View view) {
return showCheatSheet(view, view.getContentDescription());
}
});
代码示例来源:origin: facebook/litho
final String oldContentDescription = oldView.getContentDescription().toString();
final Drawable oldBackground = oldView.getBackground();
final String newContentDescription = newView.getContentDescription().toString();
final Drawable newBackground = newView.getBackground();
代码示例来源:origin: GadgetCheck/TinderView
@Override
public boolean onLongClick(View view) {
return showCheatSheet(view, view.getContentDescription());
}
});
代码示例来源:origin: PuffOpenSource/Puff-Android
@Override
public boolean onLongClick(View view) {
return showCheatSheet(view, view.getContentDescription());
}
});
代码示例来源:origin: stackoverflow.com
findViewById(R.id.button_edit).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Toast.makeText(context,view.getContentDescription(), Toast.LENGTH_SHORT).show();
return true;
}
});
代码示例来源:origin: stackoverflow.com
textView.setText(yourText.replaceAll("[0-9]",""));
textView.setContentDescription(yourText);
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String str = ((TextView) v.getContentDescription()).toString();
}
});
代码示例来源:origin: fr3ts0n/AndrOBD
/**
* OnClick handler - Browse URL from content description
* @param view view source of click event
*/
public void browseClickedUrl(View view)
{
String url = view.getContentDescription().toString();
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public S hasContentDescription(CharSequence contentDescription) {
isNotNull();
CharSequence actualContentDescription = actual.getContentDescription();
assertThat(actualContentDescription) //
.overridingErrorMessage("Expected content description <%s> but was <%s>",
contentDescription, actualContentDescription) //
.isEqualTo(contentDescription);
return myself;
}
代码示例来源:origin: hencoder/PlusDemo
@Override
public boolean onLongClick(View v) {
ClipData imageData = ClipData.newPlainText("name", v.getContentDescription());
return ViewCompat.startDragAndDrop(v, imageData, new DragShadowBuilder(v), null, 0);
}
};
代码示例来源:origin: fookwood/Launcher3
@Thunk void selectTile(View v) {
if (mSelectedTile != null) {
mSelectedTile.setSelected(false);
mSelectedTile = null;
}
mSelectedTile = v;
v.setSelected(true);
mSelectedIndex = mWallpapersView.indexOfChild(v);
// TODO: Remove this once the accessibility framework and
// services have better support for selection state.
v.announceForAccessibility(
getContext().getString(R.string.announce_selection, v.getContentDescription()));
}
代码示例来源:origin: appium/appium-espresso-driver
public Element (View view) {
ELEMENT = UUID.randomUUID().toString();
cache.put(ELEMENT, view);
// Cache the content description as well
CharSequence contentDesc = view.getContentDescription();
if (contentDesc != null) {
contentDescriptionCache.put(ELEMENT, contentDesc.toString());
}
}
代码示例来源:origin: pranavpandey/dynamic-support
@Override
public boolean onLongClick(View v) {
DynamicHint.show(v, DynamicHint.make(DynamicTheme.getInstance().getContext(),
v.getContentDescription(), mActionCustom.getCurrentTextColor(),
((DynamicWidget) v).getColor()));
return true;
}
});
代码示例来源:origin: pranavpandey/dynamic-support
@Override
public boolean onLongClick(View v) {
DynamicHint.show(v, DynamicHint.make(DynamicTheme.getInstance().getContext(),
v.getContentDescription(), mActionCustom.getCurrentTextColor(),
((DynamicWidget) v).getColor()));
return true;
}
});
内容来源于网络,如有侵权,请联系作者删除!