-10
findViewById
에 오류가 발생합니다.메서드를 확인할 수 없습니다. findViewById (int)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bag_setting);
}
}
public class InputFilterMinMax implements InputFilter {
private int min, max;
public InputFilterMinMax(int min, int max) {
this.min = min;
this.max = max;
}
public InputFilterMinMax(String min, String max) {
this.min = Integer.parseInt(min);
this.max = Integer.parseInt(max);
}
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
try {
int input = Integer.parseInt(dest.toString() + source.toString());
if (isInRange(min, max, input))
return null;
} catch (NumberFormatException nfe) {
}
return "";
}
private boolean isInRange(int a, int b, int c) {
return b > a ? c >= a && c <= b : c >= b && c <= a;
EditText editText2 = (EditText) findViewById(R.id.editText2);
editText2.setFilters(new InputFilter[]{new InputFilterMinMax("0", "54")});
}
}
를 제거 변경을 할 수 있습니다 여기에 코드입니다 귀하의 레이아웃 XML을 게시 .... 또한 전체 오류가 나타납니다. –
'onCreate' 함수를 닫은 직후에 다른 닫는 괄호가 있습니다. 즉, 활동 인 클래스를 닫았습니다. 바로 직후에 새 클래스를 정의합니다.이 클래스는 액티비티 클래스를 둘러싸고 있지 않습니다. 그러므로 그것은 'findViewById'를 이해하지 못합니다. – 0xDEADC0DE
은 내부 클래스 인 InputFilterMinMax입니까? –