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 clos开发者_如何学运维e, is that possible to effectively switch one for the other? Or does anyone have a better trick I couldn't find?
Thanks
Why not have your TextView, then on click hide it. Then use Java to create a EditText in its place.
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.
精彩评论