「Android/UIEditText」の版間の差分
提供: 初心者エンジニアの簡易メモ
| 行24: | 行24: | ||
java | java | ||
<pre> | <pre> | ||
| − | + | // 値取得 | |
| − | + | EditText editText = (EditText)findViewById(R.id.searchBox); | |
| + | Log.d("edittext", editText.getText().toString()); | ||
| + | |||
| + | // 値設定 | ||
| + | (EditText)findViewById(R.id.zoneId)).setText("hogehoge"); | ||
</pre> | </pre> | ||
2019年8月28日 (水) 17:22時点における版
res/layout/~.xml
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search:"
/>
<EditText
android:id="@+id/searchBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:hint="searchword..."
android:singleLine="true"
/>
</LinearLayout>
java
// 値取得
EditText editText = (EditText)findViewById(R.id.searchBox);
Log.d("edittext", editText.getText().toString());
// 値設定
(EditText)findViewById(R.id.zoneId)).setText("hogehoge");
