0

In Android Studio, I want to make a program where a TextView changes to an EditView when clicked. After the user is finished typing, I want the EditText to then change back to a TextView which shows the value that was entered.

How do I do this? This is what I have so far:

loc > TextView, 
edit_loc > EditText

loc.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        loc.setVisibility(View.GONE);
        edit_loc.setVisibility(View.VISIBLE);
    }
});
Sathish Guru V
  • 1,084
  • 1
  • 11
  • 33

2 Answers2

1

You can you simple edit text view and set it clickable false when user complete the typing .. for know when user is typing or not you use this code:

 editText.addTextChangedListener(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) {
        //when user is typing
        }

        @Override
        public void afterTextChanged(Editable editable) {
         // after user complete typing
        }
    });
Amit pandey
  • 817
  • 2
  • 10
0

regarding @amit-pandey, it's not the complete solution because after each typing the TextWatcher being called

check this link, it is better solution but it's not the best

https://stackoverflow.com/a/28625726/12177115

BeNYaMiN
  • 1
  • 2