-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' у вас есть еще одна закрывающая скобка, что означает, что вы закрыли свой класс, который является активностью. Сразу после этого вы определяете новый класс, который не является закрывающим классом Activity. Поэтому он не понимает 'findViewById' – 0xDEADC0DE
является InputFilterMinMax внутренним классом? –