「Android/UIEditText」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「<pre> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:...」) |
|||
| (同じ利用者による、間の3版が非表示) | |||
| 行1: | 行1: | ||
| + | res/layout/~.xml | ||
<pre> | <pre> | ||
| − | + | <LinearLayout | |
android:orientation="horizontal" | android:orientation="horizontal" | ||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||
| 行19: | 行20: | ||
android:singleLine="true" | android:singleLine="true" | ||
/> | /> | ||
| − | + | </LinearLayout> | |
| + | </pre> | ||
| + | java | ||
| + | <pre> | ||
| + | // 値取得 | ||
| + | EditText editText = (EditText)findViewById(R.id.searchBox); | ||
| + | Log.d("edittext", editText.getText().toString()); | ||
| + | |||
| + | // 値設定 | ||
| + | ((EditText)findViewById(R.id.ad_unit_id)).setText("hogehoge"); | ||
</pre> | </pre> | ||
2019年11月5日 (火) 12:39時点における最新版
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.ad_unit_id)).setText("hogehoge");
