I want to have an edittext that has an uneditable text beside it (on the left, the beginning of the EditText). Just like this one, How do I go with this?
Asked
Active
Viewed 616 times
-1
-
Try [this](http://stackoverflow.com/questions/14195207/put-constant-text-inside-edittext-which-should-be-non-editable-android), you may get clue – Ichigo Kurosaki Oct 31 '15 at 08:15
-
The text you want to display in your edit text is static or dynamic ? – Radhey Oct 31 '15 at 11:06
-
static text! Thanks Ichigo! – J. Salonga Nov 02 '15 at 03:59
2 Answers
0
Put constant text inside EditText which should be non-editable - Android
I found this useful for those who wanted it. I haven't applied it yet but this would work, right?

Community
- 1
- 1

J. Salonga
- 13
- 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());
}
}
});
try this....

Shivanshu Verma
- 609
- 5
- 19