答案 0 :(得分:0)
Put constant text inside EditText which should be non-editable - Android
我发现这对那些想要它的人很有用。我还没有应用它,但这会起作用,对吧?
答案 1 :(得分:0)
final EditText edt = (EditText) findViewById(R.id.editText1);
edt.setText("Speed");
Selection.setSelection(edt.getText(), edt.getText().length());
edt.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
if(!s.toString().contains("http://")){
edt.setText("http://");
Selection.setSelection(edt.getText(), edt.getText().length());
}
}
});
试试这个......