I already told you that I tried a similar approach with a ViewSwitcher. There is no need to extend a LinearLayout for this task if there is a pre built ViewSwitcher. The problem with this pattern is that the user click is eaten by the SwapView, so the user has to click another time in the EditText to focus it and show the soft keyboard. I want that when the user long taps my custom view, a soft keyboard is shown if necessary and he can start typing (without having to click it one more time)
2011/10/7 Studio LFP <[email protected]> > 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<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 > -- 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

