レイアウトにTableLayout
動的ビューが追加されています。レイアウトにEditText
カーソルが表示されていないときはいつでもEditText
、上にカーソルが表示されEditText
ますTextView
。
onClick
イベント、両方の XML ファイル、Edittext
およびTextview
メイン レイアウトの XMLファイルを追加しました。
私のtextview
聞き手:
textView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
textView.setSelection(textView.getText().toString().length());
textView.requestFocus();
textView.requestFocusFromTouch();
textView.setCursorVisible(true);
return false;
}
});
XML ファイル:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbars="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:focusable="true"
android:focusableInTouchMode="false"
android:text="@string/title_form_details"
android:textSize="25dp" />
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fieldsContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:shrinkColumns="1"
android:stretchColumns="1" >
</TableLayout>
</LinearLayout>
</ScrollView>
TextView
XML ファイル:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
android:paddingBottom="0dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
/>
EditText
XML ファイル:
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/control"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:textColor="#000000"
android:textCursorDrawable="@null"
/>
動的に追加TextView
し、次の行にEdittext
ビューを追加していますが、をクリックするたびにEditText
カーソルが上に表示されTextView
ます。