开发者

Focus on the first edtitext in android

开发者 https://www.devze.com 2023-04-06 08:38 出处:网络
I have four edittexts the p开发者_Go百科roblem is when i start activity the focus will be on the last edittext , how can i make the focus on the first edittext using xml ?

I have four edittexts the p开发者_Go百科roblem is when i start activity the focus will be on the last edittext , how can i make the focus on the first edittext using xml ? Thanks


onCreate(); of Activity

EditText firsteditText=(EditText)findViewById(R.id.first);
EditText secondeditText=(EditText)findViewById(R.id.second);
EditText thirdeditText=(EditText)findViewById(R.id.third);
EditText fourtheditText=(EditText)findViewById(R.id.fourth);

     firsteditText.requestFocus();


You can use the requestFocus element.


You can also add a <requestFocus/> tab in the activity xml.


In Android Studio 2.3.3, you can click on the focusedByDefault attribute in the Properties panel on the EditText you want the focus on first.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号