Thanks for your reply, but in my real application I have two nested LinearLayout which make up a table. This table is comprised of CustomEditText, so your solution isn't appliable here. I appreciate your effort, but I need a solution based on the above pattern. I also tried to use a ViewSwitcher to switch between a TextView and an EditText, but it seems a performance hit, since I have a 7x7 table and so I need to instantiate 49 ViewSwitcher besides the 49 TextViews and 49 EditText
2011/10/7 Studio LFP <[email protected]> > Here is something I came up. I haven't worked out all the details, but > maybe this will get you started. > > It works by using a RelativeLayout and when you tap on a TextView, it just > sets the bounds of an EditText to match the TextView. It then hides the > TextView and layers the EditText on the invisible view. I know I didn't > handle the click-change-color and long-click-change-view idea, but these > should be fairly easy to add. > > ---- XML Layout: swap_view.xml --- > <?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"> > <TextView android:id="@+id/tvReplace" > android:layout_width="match_parent" android:layout_height="40dp" > android:text="Test Text" android:textSize="20dp" /> > </RelativeLayout> > > ---- Activity Code ---- > public class SwapViewActivity extends Activity implements OnClickListener > { > private RelativeLayout rlHolder; > > @Override > > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > setContentView( R.layout.swap_view ); > > rlHolder = (RelativeLayout)findViewById( R.id.rlHolder ); > > TextView tvReplace = (TextView)findViewById( R.id.tvReplace ); > tvReplace.setOnClickListener( this ); > } > > @Override > public void onClick( View v ) > { > switch( v.getId() ) > { > case R.id.tvReplace: > { > RelativeLayout.LayoutParams rlpParams = new > RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, > LayoutParams.MATCH_PARENT ); > rlpParams.addRule( RelativeLayout.ALIGN_LEFT, v.getId() ); > rlpParams.addRule( RelativeLayout.ALIGN_TOP, v.getId() ); > rlpParams.addRule( RelativeLayout.ALIGN_RIGHT, v.getId() ); > rlpParams.addRule( RelativeLayout.ALIGN_BOTTOM, v.getId() > ); > > v.setVisibility( View.INVISIBLE ); > > EditText etReplace = new EditText( this ); > etReplace.setText( ((TextView)v).getText() ); > rlHolder.addView( etReplace, rlpParams ); > > break; > } > } > } > } > > You can then handle the edit and either hide or remove the EditText, set > the TextView text to the new text, and make the TextView visible again. > > 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

