由网友(痴梦)分享简介:我想转换成TextView的编辑在android的一个按钮单击事件文本,反之亦然。我不知道如何做到这一点,请帮助,如果有人知道的解决方案。I want to convert TextView into Edit Text and vice versa in a button click event in androi...
我想转换成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");
}
相关推荐
最新文章