안드로이드의 버튼 클릭 이벤트에서 TextView를 텍스트 편집으로 변환하고 그 반대의 경우도 마찬가지입니다. 나는 이것을 달성하는 방법을 모른다. 누군가가 해결책을 안다면 도울 수있다.안드로이드에서 TextView를 EditText로 변환하는 방법?
감사합니다, Rajapandian.K
안드로이드의 버튼 클릭 이벤트에서 TextView를 텍스트 편집으로 변환하고 그 반대의 경우도 마찬가지입니다. 나는 이것을 달성하는 방법을 모른다. 누군가가 해결책을 안다면 도울 수있다.안드로이드에서 TextView를 EditText로 변환하는 방법?
감사합니다, Rajapandian.K
어쩌면 각 중 하나가 자신의 가시성을 전환 할 수 있습니다. 버튼을 클릭하면 표시되는 텍스트를 가져와 보이지 않는 텍스트에 적용한 다음 가시성을 바꿉니다.
레이아웃에 둘 다있을 수 있으며 항상 둘 중 하나만 표시 할 수 있습니다. EditText 값이 변경되면 숨겨진 TextView를 업데이트하여 동기화하십시오.
@ 부자 : 좋아, 당신은 내가 정직에서 생각하는 빠른 –
나는 결코 시도하지 못했지만 (아마도) EditText를 사용하고 TextView의 배경을 설정할 수 있습니다. 그런 다음 onfocus
변경하면 주어진 순간에보고 싶은 것을 바탕으로 배경을 바꿀 수 있습니다. 그것이 작동 있을지 나는 그것을 구현하고보고하려고합니다
...
<ViewSwitcher
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_switcher"
android:layout_width="match_parent"
android:layout_height="match_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="match_parent"
android:layout_height="wrap_content"
android:hint="@string/some_value" />
</ViewSwitcher>
...
그럼 당신은 내가 가장에 생각 무엇
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");
}
하여보기를 전환 할 수있는 ViewSwitcher를 사용하는 것이 가장 실제로 Framelayout 개념을 사용하십시오.
원래 레이아웃이 같은 FrameLayout이 내부
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
.
.
.
</Linearlayout>
같은 장소를 같은 보이는 것이다.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
.
.
.
</Linearlayout>
<!-- The Magic is here -->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
여기서 LinearLayout은 모든 EditText보기를 유지합니다. 또한 EditText View의 배경을 null로 만드는 것을 잊지 마십시오. 이
<EditText
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="@+id/editInp"
android:hint="@string/hello_world"
android:background="@null"
android:singleLine="true"
android:inputType="textCapWords"/>
또는
<EditText
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="@+id/editInp"
android:hint="@string/hello_world"
android:background="@android:drawable/transparent"
android:singleLine="true"
android:inputType="textCapWords"/>
@MarvinLabs처럼
: +1, 그는 빠른했다) –