2014-11-13 5 views
6

मेरे पास दो खंडों में फैले कुछ संपादन टेक्स्ट हैं।एंड्रॉइड एडिटटेक्स्ट अगला फोकस

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" > 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/cool_button" 
     android:gravity="center" 
     android:text="@string/user_account" 
     android:textAppearance="?android:attr/textAppearanceMediumInverse" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@color/yellow" 
     android:gravity="center" 
     android:padding="10dp" 
     android:text="@string/registration_description1" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="@string/email_address" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textStyle="bold" /> 

      <EditText 
       android:id="@+id/et_email_address" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:ems="10" 
       android:hint="@string/required" 
       android:inputType="textEmailAddress" > 
      </EditText> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.4" 
       android:gravity="center_vertical" 
       android:text="@string/email_address_confirmation" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textStyle="bold" /> 

      <EditText 
       android:id="@+id/et_email_address_confirm" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.6" 
       android:ems="10" 
       android:hint="@string/required" 
       android:inputType="textEmailAddress" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/tv_title" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="@string/title" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textStyle="bold" /> 

      <Spinner 
       android:id="@+id/sp_title" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       tools:listitem="@android:layout/simple_spinner_dropdown_item" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="@string/first_name" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textStyle="bold" /> 

      <EditText 
       android:id="@+id/et_first_name" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:ems="10" 
       android:hint="@string/required" 
       android:inputType="textCapWords" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="@string/surname" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textStyle="bold" /> 

      <EditText 
       android:id="@+id/et_surname" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:ems="10" 
       android:hint="@string/required" 
       android:imeOptions="actionDone" 
       android:inputType="textCapWords" /> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

और अन्य लेआउट:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:isScrollContainer="false" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" > 

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

     <TextView 
      android:id="@+id/title" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/cool_button" 
      android:gravity="center" 
      android:text="@string/title_fragment_register_business_and_contact_details" 
      android:textAppearance="?android:attr/textAppearanceMediumInverse" /> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/business_name" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_business_name" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:hint="@string/required" 
        android:inputType="textCapWords" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="match_parent" 
        android:gravity="center_vertical" 
        android:text="@string/street_name_and_number" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_street1" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="match_parent" 
        android:hint="@string/required" 
        android:inputType="textCapWords" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/street2_bigger" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_street2" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:inputType="textCapWords" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/street3_bigger" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_street3" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:inputType="textCapWords" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/street4_bigger" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_street4" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:inputType="textCapWords" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/town_or_city" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_town" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:hint="@string/required" 
        android:inputType="textCapWords" 
        android:nextFocusDown="@+id/et_county" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/county" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_county" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:hint="@string/required" 
        android:inputType="textCapWords" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="10dp" 
       android:layout_marginTop="10dp" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/country" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/united_kingdom" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/postcode" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_postcode" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:hint="@string/required" 
        android:inputType="textCapCharacters" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/business_tel" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_business_tel" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:hint="@string/required" 
        android:imeOptions="actionNext" 
        android:nextFocusDown="@+id/et_business_email" 
        android:inputType="phone" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/business_email" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_business_email" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:imeOptions="actionNext" 
        android:inputType="textEmailAddress" 
        android:nextFocusDown="@+id/et_website" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:text="@string/website" 
        android:textStyle="bold" /> 

       <EditText 
        android:id="@+id/et_website" 
        android:layout_width="0dp" 
        android:layout_weight="0.5" 
        android:layout_height="wrap_content" 
        android:imeOptions="actionDone" 
        android:inputType="textWebEditText" > 
       </EditText> 
      </TableRow> 
     </TableLayout> 
    </LinearLayout> 

</ScrollView> 

जब मैं et_business_tel पर अगले दबाते हैं, तो यह अन्य टुकड़े EditText को जाता है टुकड़े में से एक निम्नलिखित XML लेआउट है। कभी-कभी यह et_email_address_confirm पर जाता है, अन्य यह et_first_name पर जाता है। यह et_business_email में भी होता है। मैंने एंड्रॉइड की कोशिश की: अगला फोकस डाउन लेकिन यह काम नहीं कर रहा है। क्या मैं कुछ गलत कर रहा हूं या अगली बटन को अगले संपादन टेक्स्ट पर ध्यान केंद्रित करने का कोई तरीका है?

उत्तर

3

आप प्रोग्रामिक रूप से निर्णय ले सकते हैं कि आपका अगला संपादन फोकस करने के लिए अगला है।

ऑन एडिटर एक्शन लिस्टर अपने संपादन टेक्स्ट में और फोकस का अनुरोध करने के लिए अगला संपादन टेक्स्ट बनाएं।

oneEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { 
     public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) { 

      if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_GO || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { 
       YourOtherEditText.requestFocus(); 
       return true; 
      } else { 
       return false; 
      } 
     } 
    }); 
+0

के बाद से मैं अपने खुद के जवाब में पाया गया है कि मैं इस परीक्षण नहीं किया। लेकिन वैसे भी धन्यवाद। –

0

मैं इसे एक समाधान खोजने में कामयाब रहा। मेरे पास scrollView के अंदर दूसरा टुकड़ा था और जब मैंने scrollView को हटा दिया, तो अगले बटन ठीक से काम करना शुरू कर दिया।

केवल एक चीज जिसे मैं जवाब नहीं दे सकता हूं ... क्यों वैसे भी धन्यवाद।

+0

यदि आपके पास संपादन टेक्स्ट के साथ दो टुकड़े (दूसरे के शीर्ष पर) हैं, तो दृश्यमान खंड पर अगला बटन इसके पीछे के फ़ील्ड पर संपादन टेक्स्ट पर ध्यान केंद्रित कर सकता है। आपको रोकें() में पृष्ठभूमि खंड में संपादन टेक्स्ट फ़ील्ड को अक्षम करना चाहिए। यही कारण है कि अपनी स्क्रॉल छुपाएं देखें जो आपके संपादन को लपेटता है पहले खंड के अगले फ़ील्ड आपके फोकस मुद्दों को हल करता है। चीयर्स! – portfoliobuilder

7

android:nextFocusDown="@+id/et_business_email" अगले फोकस पाठ संपादन

+2

एंड्रॉइड जोड़ने का प्रयास करें: imeOptions = "actionNext" अगर यह अगले फोकस तत्व – TheIT

8

मैं इस प्रयोग किया जाता है करने के लिए अपने जाने, यह मेरे लिए काम किया:

android:imeOptions="actionNext" 
android:nextFocusRight="@+id/staff" 
+1

एंड्रॉइड को परिभाषित करने के बाद काम नहीं कर रहा है: imeOptions = "actionNext" ने चाल की है! – TheIT

संबंधित मुद्दे