안녕 viewswitcher
을 사용하여 TextView
과 EditText
사이를왔다 갔다합니다. 내보기가 textview
에서 edittext
으로 전환됩니다. 그러나 다시 전환하지 않습니다. 여기 내 xml
입니다 : 스위칭을위한ViewSwitcher 이전보기로 돌아 가기
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/noteItemVS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="@+id/noteItemTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:text="textview"
android:textAlignment="center" />
<EditText
android:id="@+id/noteItemEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="edittext"
android:textAlignment="center" />
</ViewSwitcher>
내 코드입니다 : 내가 문제를 해결할 수 있었다 뷰 스위처 치우는으로
protected void switchViews(NoteItem note) {
ViewSwitcher switcher = (ViewSwitcher) context.findViewById(R.id.noteItemVS);
View switchCheck = switcher.getCurrentView();
if (switchCheck instanceof EditText) {
EditText l = (EditText)switchCheck ;
String x = l.getText().toString();
Log.e("tree",x);
if (!x.isEmpty()) {
switcher.showPrevious();
TextView myTV = (TextView) switcher.findViewById(R.id.noteItemTextView);
myTV.setText(x);
}
}
; if (switchCheck instanceof TextView) {
TextView l = (TextView) switchCheck;
String x = l.getText().toString();
switcher.showNext();
EditText myEditText = (EditText) switcher.findViewById(R.id.noteItemEditText);
myEditText.setText(x);
}
}
또한 ViewPager를 사용 수, 또한 간단한 View.Visible 및 View.Gone 구현 –