如何在Android上更改光标位置

时间:2018-07-05 18:17:33

标签: android-cursor

我想在android中更改光标。 当我写在另一个Edit Text上的一个EditText光标中时。 我使用此代码,但没有得到正确的答复;

public class Word4Activity extends AppCompatActivity {
EditText edt1;
EditText edt2;
EditText edt3;
EditText edt4;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_word4);
    initViews();
    edt1.addTextChangedListener(edt1TextWatcher);

}

TextWatcher edt1TextWatcher=new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {


    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
        edt2.setSelection(0);
    }
};
public void initViews(){
    edt1=(EditText)findViewById(R.id.activity_word4_edt1);
    edt2=(EditText)findViewById(R.id.activity_word4_edt2);
    edt3=(EditText)findViewById(R.id.activity_word4_edt3);
    edt4=(EditText)findViewById(R.id.activity_word4_edt4);


}

谢谢

0 个答案:

没有答案
相关问题