我想在mytextWatcher的aftertextchanged方法上将textdown倒计时器值设置为textview当用户在edittext中输入一些文本但值没有设置为textview时发生这一切。 这是我的代码:
适配器类中的:
public View getView(int i, View view, ViewGroup viewGroup) {
/* LayoutInflater vi = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);*/
View rowView = view;
if (rowView == null) {
final LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.items_visitorlist, null);
TextView edtxtotp = (EditText) rowView.findViewById(R.id.edtxtotp);
txttimer = (TextView) rowView.findViewById(R.id.txttimer);
edtxtotp.addTextChangedListener(new MyTextWatcher(edtxtotp) );
textwatcher类中的
@Override
public void afterTextChanged(Editable s) {
EditText edtxtotp = (EditText) view.findViewById(R.id.edtxtotp);
//final TextView txttimer = (TextView) view.findViewById(R.id.txttimer);
Toast.makeText(context, "Hi"+otp, Toast.LENGTH_LONG).show();
if(edtxtotp.getText().toString().length()>=4) {
Toast.makeText(context, "Hi", Toast.LENGTH_LONG).show();
new CountDownTimer(60000,1000)
{
@Override
public void onTick(long l) {
txttimer.setText("testing");
counter--;
}
@Override
public void onFinish() {
txttimer.setText("Finish");
}
}.start();
}
else
{
Toast.makeText(context, "Maximum level reached", Toast.LENGTH_LONG).show();
}
}
}