在我的課程中,我創建了兩個EditTexts。多個EditText - 指定光標的位置
editText1 = (EditText)findViewById(R.id.EditText1);
editText2 = (EditText)findViewById(R.id.EditText2);
當我啓動應用程序時,光標自動放在第二個EditText中。如何更改爲在第一個EditText中設置?我應該改變一些程序或XML嗎?
在我的課程中,我創建了兩個EditTexts。多個EditText - 指定光標的位置
editText1 = (EditText)findViewById(R.id.EditText1);
editText2 = (EditText)findViewById(R.id.EditText2);
當我啓動應用程序時,光標自動放在第二個EditText中。如何更改爲在第一個EditText中設置?我應該改變一些程序或XML嗎?
你可以試試:
editText1.requestFocus();
這取決於誰要求重點。獲取要獲得焦點並請求焦點的對象,該對象將亮起,並且光標應顯示在那裏。
有這樣一個在你的班級像
editText1.requestFocus();
,另一個在XML像
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
請上傳您的AndroidManiFest兩種方式。 xml文件的代碼 – Lucifer 2012-02-02 12:28:21