本文整理汇总了Java中android.view.View.getContentDescription方法的典型用法代码示例。如果您正苦于以下问题:Java View.getContentDescription方法的具体用法?Java View.getContentDescription怎么用?Java View.getContentDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getContentDescription方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showHeadView
import android.view.View; //导入方法依赖的package包/类
private void showHeadView(){
headerLayout.setTranslationY(0);
View underView = rightMenu.findChildViewUnder(headerView.getX(),0);
if(underView!=null && underView.getContentDescription()!=null){
int position = Integer.parseInt(underView.getContentDescription().toString());
DishMenu menu = rightAdapter.getMenuOfMenuByPosition(position+1);
headMenu = menu;
headerView.setText(headMenu.getMenuName());
for (int i = 0; i < dishMenuList.size(); i++) {
if (dishMenuList.get(i) == headMenu) {
leftAdapter.setSelectedNum(i);
break;
}
}
}
}
示例2: onResume
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onResume(){
super.onResume();
View root = this.getWindow().getDecorView();
for(View v : TreeIterables.breadthFirstViewTraversal(root)){
if(v.getId() != -1) {
System.out.println("View: " + v.getResources().getResourceEntryName(v.getId()) + " " + v.isClickable());
} else if(v.getContentDescription() != null){
System.out.println("View: " + v.getContentDescription().toString() + " " + v.isClickable());
} else{
System.out.println("View: " + v.toString() + " No Des, No Id " + v.isClickable());
}
}
}
示例3: showButtonDescription
import android.view.View; //导入方法依赖的package包/类
/**
* Procedure hows toast that contains description of the given button
*/
@SuppressLint("RtlHardcoded")
public static boolean showButtonDescription(Context context, View button)
{
CharSequence contentDesc = button.getContentDescription();
if (contentDesc != null && contentDesc.length() > 0)
{
int[] pos = new int[2];
button.getLocationOnScreen(pos);
Toast t = Toast.makeText(context, contentDesc, Toast.LENGTH_SHORT);
t.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0);
t.getView().measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
final int x = pos[0] + button.getMeasuredWidth() / 2 - (t.getView().getMeasuredWidth() / 2);
final int y = pos[1] - button.getMeasuredHeight() / 2 - t.getView().getMeasuredHeight()
- context.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
t.setGravity(Gravity.TOP | Gravity.LEFT, x, y);
t.show();
return true;
}
return false;
}
示例4: traverseNode
import android.view.View; //导入方法依赖的package包/类
private ArrayList<CopyNode> traverseNode(View nodeInfo, int screenWidth, int scerrnHeight) {
ArrayList nodeList = new ArrayList();
if(nodeInfo != null ) {
if (!nodeInfo.isShown()){
return nodeList;
}
if (nodeInfo instanceof ViewGroup){
ViewGroup viewGroup = (ViewGroup) nodeInfo;
for(int var4 = 0; var4 < viewGroup.getChildCount(); ++var4) {
nodeList.addAll(this.traverseNode(viewGroup.getChildAt(var4), screenWidth, scerrnHeight));
}
}
if(nodeInfo.getClass().getName() != null && nodeInfo.getClass().getName().equals("android.webkit.WebView")) {
return nodeList;
} else {
String content = null;
String description = content;
if(nodeInfo.getContentDescription() != null) {
description = content;
if(!"".equals(nodeInfo.getContentDescription())) {
description = nodeInfo.getContentDescription().toString();
}
}
content = description;
String text=getTextInFilters(nodeInfo,mFilters);
if(text != null) {
content = description;
if(!"".equals(text)) {
content = text.toString();
}
}
if(content != null) {
Rect var8 = new Rect();
nodeInfo.getGlobalVisibleRect(var8);
if(checkBound(var8, screenWidth, scerrnHeight)) {
nodeList.add(new CopyNode(var8, content));
}
}
return nodeList;
}
} else {
return nodeList;
}
}
示例5: getResName
import android.view.View; //导入方法依赖的package包/类
protected static String getResName(View v){
if(v == null) return "";
if(v.getId() == -1){
if(v.getContentDescription() != null) {
return v.getContentDescription().toString();
} else {
return "";
}
}else {
return v.getResources().getResourceEntryName(v.getId());
}
}
示例6: onLongClick
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
CharSequence description = v.getContentDescription();
if (!TextUtils.isEmpty(description)) {
Toast.makeText(mContext, description, Toast.LENGTH_SHORT).show();
}
return true;
}