I want to allow the user to edit just part of a line of text in my Android app. I see a class called the EasyEditSpan but when I stick it into a TextView nothing happens. I tried making the TextView editable but it still doesn't have any effect. If switch to an EditText then the whole line of text is editable which is also incorrect. Here is my code:
@Override
public void onCreate(Bundle savedInstanceState) {
TextView testView = (TextView)findViewById(R.id.text_view);
testView.setText(buildMiddleEditSpannable("Please enter your ", "Name", " here."));
}
public static Spannable buildMiddleEditSpannable(CharSequence beginning, CharSequence middle, CharSequence end) {
int spanMidStart = beginning.length();
int spanMidEnd = spanMidStart + middle.length();
SpannableString span = new SpannableString(new StringBuilder(middle).insert(0, beginning).append(end));
span.setSpan(new EasyEditSpan(), spanMidStart, spanMidEnd, 0);
return span;
}