, here
발견
setAllCaps 메서드는 setTransformationMethod
메서드를 사용하여 변환 메서드를 해당 뷰로 설정합니다.
setAllCaps
방법의 경우 AllCapsTransformationMethod
입니다. 따라서보기가 설정되어 있는지 여부를 얻을 여부를이 사용하여 확인할 수 있습니다
은 BTN가
또는 대안이 버튼 있는지 확인하는 그것의 방법을 당신의 버튼이다
TransformationMethod transformationMethod = btn.getTransformationMethod();
if (transformationMethod!=null){
if (transformationMethod.getClass().getSimpleName().equalsIgnoreCase(AllCapsTransformationMethod.class.getSimpleName())){
// todo logic based code
}
/텍스트 뷰 모두가 캡 설정하거나이 같은하지
뭔가 값 :
public boolean hasAllCaps(TextView textView){
TransformationMethod transformationMethod = textView.getTransformationMethod();
if (transformationMethod!=null)
if (transformationMethod.getClass().getSimpleName().equalsIgnoreCase(AllCapsTransformationMethod.class.getSimpleName())){
return true;
}
return false;
}
그리고 단지 값을 확인!
textview.getText()는 strings.xml에서 유지 관리하는 형식 (예 : 텍스트 레이블 : 열기)을 항상 반환합니다. 모든 대문자로 표시해야합니다. 그래서 나는 다른 곳에서 그 라벨을 사용해야 할 수도 있기 때문에 textAllCaps 속성을 사용하고 있습니다. 자동화 목적으로, 텍스트가 allCaps에 있는지 여부를 코드에서 검증해야합니다. strings.xml에서 레이블을 "OPEN"로 유지하면 getText()가 정상적으로 작동합니다. 문제는, textAllCaps @run 시간을 확인할 수 없다는 것입니다. – DayanaK
그럴 경우, 프로그램 적으로 레이블을 설정할 수 있다고 생각합니까? Resource 클래스를 사용하여 Resource 클래스를 가져온 다음 String toUpperCase() 메서드를 사용하여 TextView로 설정합니다. 그렇게하면 자동 유효성 검사를 수행 할 때 getText() 메서드는 String을 대문자로 반환합니다. –