Reputation: 658
I have a TextView
TextView name = (TextView) layout.findViewById(R.id.textviewid);
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//stuff
}
});
Now, when clicking this TextView, it should "transform" to sort of an EditText, in which I can input my new text and complete the procedure by hitting Enter.
I have seen Options, in which another EditText provides the new text, or in which a static text is added.
In my case, however, I don't want any other popup or new View to appear.
I just want to set the new text in place, like an EditText, without the constant TextBox of an EditText.
Is this possible and if so, how?
Upvotes: 0
Views: 1375
Reputation: 2152
If you want to remove the textbox of the editable then you simply use this attribute to style the editbox
android:background="@android:color/transparent"
If you want to edit a textview you can use the following attribute
android:editable="true"
In actual code a TextView and an EditText is actually the same. An Edit text is simply a textView with things added on.
Upvotes: 1
Reputation: 630
You could just extend de EditText
class overriding the getView
method to display as a TextView
. This way you'd have an EditText
and user would think it is in fact a TextView
. However, I wouldn't recommend to do this because the view would be misleading and users wouldn't know the TextView
is editable.
Upvotes: 0