In my activity there is a button and a textview .What I am trying is when the user clicks on a button the keyboard shows up ,and whatever the user types there that text should be displayed in textview.I'm able to show keyboard on button click but can't get the text in textview. I tried textview.setFocusableInTouchMode (true); & textview.requestFocus ();
on button click ,but still can't get the text.
As suggested, I added edittext instead of textview and also added text changed listener on it , but not able to achieve what I want .The keyboard should appear on button click and then show the text in edittext .
you can solve this in 2 ways
method 1:
add textChangeListener to your EditText, like this
yourEditText.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) {
yourTextView.setText(charSequence);
}
@Override
public void afterTextChanged(Editable editable) {
}
});
method 2:
use the only editText and set EditText background color same as your screen background color then your editText will look like a textView and automatically typed value will be there
like this :
android:background="your screen background color"
This might help you