Along with the above code you could add an "Ok" button to the side of the edit text to accept the input and revert back to a TextView.
Steven Studio LFP http://www.studio-lfp.com On Friday, October 7, 2011 12:02:52 PM UTC-5, Studio LFP wrote: > > Using a simple technique, and should be usable anywhere. > > <?xml version="1.0" encoding="utf-8"?> > <RelativeLayout android:id="@+id/rlHolder" xmlns:android=" > http://schemas.android.com/apk/res/android" android:orientation="vertical" > android:layout_width="match_parent" android:layout_height="match_parent"> > <com.testproject.views.SwapView android:id="@+id/svReplace" > android:layout_width="match_parent" android:layout_height="40dp" > android:text="Test Text" android:textSize="20dp" /> > </RelativeLayout> > > public class SwapView extends LinearLayout > { > public static final int TYPE_TEXT = 0; > public static final int TYPE_EDIT = 1; > > public int iType = 0; > public String sText = "Text"; > > private LinearLayout.LayoutParams llpParams = new > LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, > LayoutParams.MATCH_PARENT ); > private Context context; > > public SwapView(Context newContext) { super(newContext); context = > newContext; setInitialView(); } > public SwapView(Context newContext, AttributeSet attrs) { > super(newContext, attrs); context = newContext; setInitialView(); } > > private void setInitialView() > { > TextView tvNew = new TextView( context ); > tvNew.setText( sText ); > addView( tvNew, llpParams ); > } > > public void setActiveType( int iNewType ) > { > this.removeAllViews(); > > iType = iNewType; > > switch( iNewType ) > { > case TYPE_TEXT: > TextView tvNew = new TextView( context ); > tvNew.setText( sText ); > addView( tvNew, llpParams ); > break; > > case TYPE_EDIT: > EditText etNew = new EditText( context ); > etNew.setText( sText ); > addView( etNew, llpParams ); > break; > } > } > } > > Steven > Studio LFP > http://www.studio-lfp.com > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

