String 회전 Float 질문
3178 단어 일상적인 문제
현재 자신의 해결 방안은 문자열에 대한 수동 판단입니다!구체적인 코드는 다음과 같습니다.
EditText et = (EditText) rootView.findViewById(R.id.et);
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String str = s.toString();
if (TextUtils.isEmpty(str)) {
return;
}
int firstIdex = str.indexOf(".");
int lastIndex = str.lastIndexOf(".");
if (firstIdex == lastIndex && firstIdex != 0) {//
Float valueOf = Float.valueOf(str);
float float1 = Float.parseFloat(str);
Log.e("zhilong", valueOf + "--" + float1);
} else {
if (str.length() == 1) {
et.setText("");
} else {
et.setText(str.substring(0, str.length() - 1));
et.setSelection(str.length()-1);
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
nginx 정적 파일 설정 의 루트 와 alias1. 루트 를 사용 하여 이 경 로 를 일치 시 킬 때 location 뒤에 일치 하 는 이 경 로 는 파일 디 렉 터 리 에 실제 존재 해 야 합 니 다. 접근 할 때 자동 으로 추 가 됩 니 다 "/" 를 추가 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.