Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert TextView to EditText in android?

Tags:

android

I want to convert TextView into Edit Text and vice versa in a button click event in android. I don't know how to achieve this , please help if anyone knows the solution.

Regards, Rajapandian.K

like image 402
Rajapandian Avatar asked Nov 18 '10 11:11

Rajapandian


People also ask

How to change EditText to TextView?

Put your EditText and TextView into FrameLayout or RelativeLayout and just do setVisibility() on them hidding one and showing another when needed. Show activity on this post. And change visibility of EditText or TextView from code, whenever you want. Note: for default TextView invisible.

How do you gradient text on Android?

setTextColor() with the first color of the gradient. Then the screenshot: What works is to have, for instance, a white color setup as text color in the first place. Then we can apply the shader, and it will be applied on top of the white so we will get the desired gradient color.


1 Answers

Best to use a ViewSwitcher

...     <ViewSwitcher         xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@+id/my_switcher"         android:layout_width="match_parent"         android:layout_height="match_parent" >          <TextView             android:id="@+id/clickable_text_view"             android:clickable="true"             android:onClick="TextViewClicked"             android:text="@string/some_value" />          <EditText             android:id="@+id/hidden_edit_view"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:hint="@string/some_value" />     </ViewSwitcher> ... 

Then you can switch the views by

public void TextViewClicked() {     ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.my_switcher);     switcher.showNext(); //or switcher.showPrevious();     TextView myTV = (TextView) switcher.findViewById(R.id.clickable_text_view);     myTV.setText("value"); } 
like image 133
joneswah Avatar answered Sep 19 '22 06:09

joneswah