1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Android]初回にEditTextにフォーカスを当てる

Posted at

目的

アプリを開いたときや、特定のページに遷移した時に画面内のEditTextにフォーカスを当ててキーボードを表示させておく方法

内容

ここでXMLファイルのEditTextのタグを拡張してrequestFocusタグを内部に追加します

activity_second.xml
<EditText
     android:id="@+id/editText"
     android:layout_width="0dp"
     android:layout_height="wrap_content"
     android:hint="ここに入力してね"
     app:layout_constraintEnd_toEndOf="parent"
     app:layout_constraintStart_toStartOf="parent"
     app:layout_constraintTop_toTopOf="parent" >
   <requestFocus/>
</EditText>

こうすることで読み込み時にフォーカスをEditTextに当てることができます

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?