如何TextView的转换的EditText android系统中? [英] How to convert TextView to EditText in android?

查看:134
本文介绍了如何TextView的转换的EditText android系统中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换成TextView的编辑在android的一个按钮单击事件文本,反之亦然。我不知道如何做到这一点,请帮助,如果有人知道的解决方案。

I want to convert TextView into Edit Text and vice versa in a button click event in android. I don't know how to achieve this , please help if anyone knows the solution.

问候, Rajapandian.K

Regards, Rajapandian.K

推荐答案

最好用ViewSwitcher

Best to use a ViewSwitcher

...
    <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>
...

然后你可以通过

Then you can switch the views by

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

这篇关于如何TextView的转换的EditText android系统中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆