views:

50

answers:

2

Hi,

The need is to make a title (TextView) tappable to edit it(EditText)...

I'm using the trick to have 1 TextView and 1 EditText next to each other in my xml layout, and then I play with .setVisibility(View.INVISIBLE/VISIBLE) to visually switch them.

Since TextView and EditText are pretty close, is that possible to effectively switch one for the other? Or does anyone have a better trick I couldn't find?

Thanks

A: 

Why not have your TextView, then on click hide it. Then use Java to create a TextEdit in its place.

Wolfy87
A: 

From my point of view, there are two ways you could accomplish this.

Since EditText derives from TextView, you could just make the EditText not editable(android:editable=false) -- and then change that attribute programatically when you want to.

The second method is to use the invisible/visible switching of the EditText and TextView.

I don't think there is a big difference between the two performance wise. Its a designer decision.

hwrdprkns
Thanks for your answer! But then, how can I change the editable attribute? there is no setEditable() method...
jobano
Interesting point. I hadn't thought about that. Maybe try using a text watcher -- although that seems a bit too involved.
hwrdprkns