2015-11-05 13 views
2

對我來說,這是一個令人困惑的行爲,我找不到其他任何人正是我的問題。actionNextNext(或任何ImeOption)在我的Edittext上不起作用,當選擇此特定選項時,我也無法選擇任何其他文本字段

我試圖創建一個登錄活動,到目前爲止,用戶名字段給了我很多麻煩。無論如何,textfield始終保持專注。

它不會失去焦點,如果我點擊外面,我不能點擊任何其他領域,我不能關閉鍵盤。只有後退按鈕才能脫身。 我試圖通過使用SingleLine,MaxLines,和Lines ....的每個組合使它成爲單行字段....我也嘗試使用ImeOptions/ImeActionId actionNext,這也沒有效果。

儘管將SingleLine設置爲true,它仍固執地保持其輸入按鈕繼續創建新行。

現在我的XML看起來是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context=".LoginActivity" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_horizontal" 
    android:paddingTop="@dimen/spacing_huge"> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/mini_logo"/> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="@dimen/spacing_huge"> 
     <ImageView 
      android:layout_width="fill_parent" 
      android:src="@drawable/orange_ring" 
      android:layout_height="fill_parent"/> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:layout_centerInParent="true"> 


      <EditText 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/loginUsername" 
       android:hint="Username" 
       android:imeOptions="actionNext" 
       android:singleLine="true"/> 

      <EditText 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/loginPassword" 
       android:hint="Password" 
       android:inputType="textPassword" 
       android:textAlignment="center" 
       android:maxLines="1" 
       android:singleLine="true" 
       android:imeActionId="6"/> 

      <Button 
       android:id="@+id/loginButton" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="login!" 
       android:onClick="userLogin"/> 

     </LinearLayout> 

    </RelativeLayout> 

</LinearLayout> 

編輯:EHM對不起,我忘了問的問題。 有人可以告訴我發生了什麼事,或者如果我誤解了某些東西或如何解決這個問題? :)我真的不知道我現在可以做什麼。謝謝你的幫助。

回答

2

結合android:maxLines="1"android:inputType="text"適合你。

0

將此行android:singleLine =「true」添加到您的EditText中。

相關問題