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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to