Use default Android Activity template to switch between editing and previewing [closed]

-1

I have a activity that serves to display the User Profile, so it lists information about this user. I want to know how does that standard already adopted by Android in ActionBar get an icon to edit the information and what was TextView , turn EditText , this is in a activity only or two?

    
asked by anonymous 04.05.2016 / 02:23

1 answer

4

In case, you 'change' a textview by edittext you can use a ViewSwitcher

Example:

- LAYOUT

<ViewSwitcher
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/my_switcher"
        android:layout_width="fill_parent"
        android:layout_height="fill_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="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/some_value" >
        </EditText>
    </ViewSwitcher>

- ACTIVITY

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");
}

However, when it comes to a lot of information, I've never come to assess whether this solution impacts performance.

In particular, in most cases, I instantiate a direct edittext in 'Enable: false' mode and when I click the button to edit I enable editable edit 'Enable: true'.

    
04.05.2016 / 13:32