Java 将EditText更改为TextView
我想将TextView改为EditText,将TextView改为EditText,因此我决定在android上使用ViewSwitcher元素,我在 然而,我仍然有一些我不明白的观点: 如何确定当前开关?例如,仅显示EditText和不可见TextView 这是我的密码:Java 将EditText更改为TextView,java,android,Java,Android,我想将TextView改为EditText,将TextView改为EditText,因此我决定在android上使用ViewSwitcher元素,我在 然而,我仍然有一些我不明白的观点: 如何确定当前开关?例如,仅显示EditText和不可见TextView 这是我的密码: 您正在使相当简单的任务复杂化。将您的EditText和TextView放入FrameLayout或RelativeLayout中,只需在它们上设置可见性,在需要时隐藏一个并显示另一个。您正在使非常简单的任务复杂化。将Edit
您正在使相当简单的任务复杂化。将您的EditText和TextView放入FrameLayout或RelativeLayout中,只需在它们上设置可见性,在需要时隐藏一个并显示另一个。您正在使非常简单的任务复杂化。将EditText和TextView放入FrameLayout或RelativeLayout中,只需在它们上设置可见性即可,在需要时隐藏一个并显示另一个。使用此选项
<RelativeLayout
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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="TextViewClicked"
android:text="@string/some_value"
android:visibility="gone"/>
<EditText
android:id="@+id/hidden_edit_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/some_value" >
</EditText>
并随时从代码更改EditText或TextView的可见性
注意:对于默认文本视图,不可见
希望能有所帮助。用这个
<RelativeLayout
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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="TextViewClicked"
android:text="@string/some_value"
android:visibility="gone"/>
<EditText
android:id="@+id/hidden_edit_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/some_value" >
</EditText>
并随时从代码更改EditText或TextView的可见性
注意:对于默认文本视图,不可见
希望能有所帮助