2013-08-07 135 views
0
<LinearLayout 
     android:id="@+id/footer" 
     android:layout_width="fill_parent" 
     android:layout_height="90dip" 
     android:layout_alignParentBottom="true" 
     android:background="@layout/footer_repeat" 
     android:orientation="vertical" > 
    </LinearLayout> 
    <!-- Footer Ends --> 


    <!-- Login Form --> 

    <LinearLayout 
     android:id="@+id/midheader" 
     android:layout_width="500dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/header" 
     android:layout_centerHorizontal="true" 
     android:orientation="vertical" 
     android:onClick="layoutClick" 
     android:padding="10dip" > 

     <!-- Email Label --> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/stk_location" 
      android:textColor="#ffffff" 
      android:textSize="20dip" /> 

     <Spinner 
      android:id="@+id/cmbstock" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dip" 
      android:layout_marginTop="5dip" 
      android:textColor="#ff0000" 
      android:textSize="50dip" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/RONO" 
      android:textColor="#ffffff" 
      android:textSize="20dip" /> 

     <EditText 
      android:id="@+id/txtRO" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dip" 
      android:layout_marginTop="5dip" 
      android:background="@drawable/back" 
      android:focusableInTouchMode="true" 

      android:inputType="text" 
      android:paddingLeft="10dp" 
      android:singleLine="true" 
      android:textColor="#000000" 
      android:textSize="35dip" 
      android:width="@dimen/padding_large" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/ITEMNO" 
      android:textColor="#ffffff" 
      android:textSize="20dip" /> 

     <EditText 
      android:id="@+id/txtItemNO" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dip" 
      android:layout_marginTop="5dip" 
      android:background="@drawable/back" 
      android:clickable="false" 
      android:cursorVisible="false" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:inputType="text" 
      android:paddingLeft="10dp" 
      android:singleLine="true" 
      android:textColor="#000000" 
      android:textSize="35dip" 
      android:width="@dimen/padding_large" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/ITEMDESC" 
      android:textColor="#ffffff" 
      android:textSize="20dip" /> 

     <EditText 
      android:id="@+id/txtItemDesc" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dip" 
      android:layout_marginTop="5dip" 
      android:background="@drawable/back" 
      android:clickable="false" 
      android:cursorVisible="false" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:inputType="text" 
      android:paddingLeft="10dp" 
      android:singleLine="true" 
      android:textColor="#000000" 
      android:textSize="35dip" 
      android:width="@dimen/padding_large" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/BIN" 
      android:textColor="#ffffff" 
      android:textSize="20dip" /> 

     <EditText 
      android:id="@+id/txtBin" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dip" 
      android:layout_marginTop="5dip" 
      android:background="@drawable/back" 
      android:inputType="text" 
      android:paddingLeft="10dp" 

      android:singleLine="true" 
      android:textColor="#000000" 
      android:textSize="35dip" 
      android:width="@dimen/padding_large" /> 

     <LinearLayout 
      android:id="@+id/botbtn" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:paddingBottom="5dip" 
      android:paddingLeft="5dip" 
      android:paddingTop="5dip" > 

      <Button 
       android:id="@+id/btnLogin" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:layout_marginRight="5dip" 
       android:layout_marginTop="2dip" 
       android:background="@drawable/bgbutton" 
       android:height="60dip" 
       android:onClick="onBtnClicked" 
       android:text="@string/btnSubmit" 
       android:textColor="#000000" 
       android:textSize="30dip" 
       android:width="240dip" /> 

      <Button 
       android:id="@+id/btnCancel" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:layout_marginLeft="5dip" 
       android:background="@drawable/bgbutton" 
       android:height="60dip" 
       android:onClick="onBtnResetClicked" 
       android:text="@string/btnReset" 
       android:textColor="#000000" 
       android:textSize="30dip" 
       android:width="240dip" /> 
     </LinearLayout> 
    </LinearLayout> 

我有四个编辑文本。当我在第一个编辑文本中输入一些值时,如果它没有焦点,则检查一个条件。现在,如果条件为假,那么焦点应该放在第一个编辑文本上,但它在最后一个。编辑文本焦点

我想如果条件strRO.equals("12345")失败,那么焦点应该是第一次编辑文本。 但目前它在最后编辑文本。

Please Healp me。

回答

0

当条件不满足......

edittext.requestFocus(); 
+0

尝试了所有的答案建议,但最后的EditText不会离开的焦点 光标是在两个编辑文本首先看到最后,但,当我键入改变最后一个 – user2651715

0

试试这个

if(!strRO.equals("12345")){ 

    editText1.requestFocus(); 

    editText4.clearFocus(); 
} 
+0

尝试了所有的答案碰巧建议,但最后的EditText不会离开的焦点 – user2651715

+0

光标是可见的两个编辑文本第一和最后但是当我输入变化发生在最后一个。 – user2651715

+0

尝试我编辑的ans它可能适用于你。 – mdDroid

0

试试:

<LinearLayout android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:layout_width="0px" 
    android:layout_height="0px" > 

    <requestFocus /> 
</LinearLayout> 

或者你可以用这种方式也:

EditText firsteditText=(EditText)findViewById(R.id.edt1); 

firsteditText.requestFocus();

+0

试过先生,但没有发生在我身边主席 – user2651715

+0

我已经尝试了很多次,并且每次都能正常工作,请确保您已妥善地将此代码放入Java代码中:EditText firsteditText =(的EditText)findViewById(R.id.txtRO); firsteditText.requestFocus();并在第一个编辑文本中尝试以下代码行:android:focusable =“true” –

相关问题