2012-12-04 13 views
5

मेरे आवेदन में मेरे पास एक पंजीकरण स्क्रीन है, बहुत सारे संपादन टेक्स्ट और स्पिनर हैं। मैं पंजीकरण क्षेत्र के माध्यम से एक-एक करके जाना चाहता हूं।एंड्रॉइड: एडिटटेक्स्ट नेक्स्टफोकसडाउन स्पिनर ट्रिगर नहीं करता

इसलिए मैंने android:imeOptions="actionNext" लागू किया। लेकिन यह सभी स्पिनरों को अनदेखा करता है। यह केवल संपादन टेक्स्ट पर ध्यान केंद्रित करेगा। मैंने भी कोशिश की है। यह स्पिनरों को भी अनदेखा करता है।

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/reportentry11" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <EditText 
      android:id="@+id/numbers" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 

      android:imeOptions="actionNext" 
      android:inputType="phone" 
      > 
      <requestFocus/> 
     </EditText> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/reportentry12" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      > 

      <TextView 
       android:id="@+id/txt_exp" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 

       android:text="EXP:" 
       android:textColor="#000000" 
       android:textSize="12dp" /> 

      <Spinner 
       android:id="@+id/spin_date" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_weight="3" 
       android:focusable="true" 
       android:focusableInTouchMode="true" 
       android:nextFocusDown="@+id/spin_year" 
       android:text="date" 
       android:textSize="12dp" /> 

      <Spinner 
       android:id="@+id/spin_year" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_marginRight="5dp" 

        android:nextFocusDown="@+id/cvc" 
       android:text="year" 
       android:textSize="12dp" /> 
     </LinearLayout> 

     <EditText 
      android:id="@+id/cvc" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:hint="@string/reg_label_cvc" 
      android:imeOptions="actionNext" 
      android:inputType="phone" /> 

     <EditText 
      android:id="@+id/fname" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/reg_label_fname" 
      android:imeOptions="actionNext" /> 

     <EditText 
      android:id="@+id/address" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/reg_label_address" 
      android:imeOptions="actionNext" /> 

     <EditText 
      android:id="@+id/city" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/reg_label_city" 
      android:imeOptions="actionNext" 
      android:nextFocusDown="@+id/pr_spin" /> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/reportentry13" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/txt_pr" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="PROV:" 
       android:textColor="#000000" 
       android:textSize="12dp" /> 

      <Spinner 
       android:id="@+id/pr_spin" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="date" 
       android:imeOptions="actionNext" 
       android:textSize="14dp" /> 

      <EditText 
       android:id="@+id/pcode" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:hint="@string/reg_label_pcode" 
       android:imeOptions="actionDone" /> 
     </LinearLayout> 

     <Button 
      android:id="@+id/register_register_button" 
      android:layout_width="wrap_content" 
      android:background="@drawable/green_button_bg" 
      android:onClick="completeClicked" 
      android:text="@string/reg_label_complete" 
      android:textSize="28dp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

मुझे स्पिनरों को गति प्रदान करने का सबसे अच्छा तरीका प्रदान करें।

+0

मुझे लगता है कि इस लिंक से आपको मदद मिलेगी .... [कड़ी] [1] [1]: http: //stackoverflow.com/questions/6443212/spinner-did-not-got-focus धन्यवाद ... – user4232

उत्तर

4

अपने ग्रंथों संपादित करें पर, onEditorAction ओवरराइड और ध्यान देने के (या अपने स्पिनर खुला तरह जो कुछ भी करते हैं) ...

yourEditTXT.setOnEditorActionListener(new OnEditorActionListener() { 
    @Override 
    public boolean onEditorAction(TextView view, int actionID, KeyEvent event) { 
      if (actionID == EditorInfo.IME_ACTION_NEXT) { 
       //do your stuff here... 
       return true; 
      } 
      return false; 
    } 
});  

संपादित 12/4: मैं तुम्हें अभी भी अंतिम के रूप में इस के साथ संघर्ष कर रहे थे देखना रात, अगर आपको कोई समाधान नहीं मिला (और एक पोस्ट नहीं किया गया) या दूसरों को पढ़ने में मदद करने के लिए, यह स्पिनर से टेक्स्ट संपादित करने में मदद कर सकता है।

mySpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());    

public class MyOnItemSelectedListener implements OnItemSelectedListener { 

     public void onItemSelected(AdapterView<?> parentview, View v, int position, long id) { 
      // your spinner proces code 
      // then when you are done, 
      yourEditText.setFocusableInTouchMode(true); //if this is not already set 
      yourEditText.requestFocus(); //to move the cursor 
      final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); 
      inputMethodManager.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); // this line and the one above will open the soft keyboard if it doesn't already open 
     } 

     public void onNothingSelected(AdapterView<?> arg0) { } 
    }; 
+0

इसकी कामकाजी लेकिन पॉपअप स्पिनर सूची नहीं दिख रही है, केवल स्पिनर – Sridhar

+0

पर प्रकाश डाला गया है @GMRamesh ने कहा है कि yourWidget.performClick() को चाल चलनी चाहिए। – logray

+0

स्पिनर के लिए संपादन करने के लिए आपका कोड काम कर रहा है, मुझे स्पिनर के लिए कोड – Sridhar

2

कर अपने xml फ़ाइल में निम्नलिखित:

<Spinnner 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:nextFocusDown="@+id/youedittextid" 
/> 
+0

@GM Ramesh पर अगले edittextid को जोड़ना होगा, यह काम नहीं कर रहा है ... – Sridhar

+0

यह मेरे लिए काम कर रहा था ... अपने कोड को अच्छी तरह से जांचें और तदनुसार बदलें ... ऐसा नहीं है कि अगर आप उपर्युक्त उत्तर पेस्ट करते हैं तो इसे काम करना चाहिए ... आपको तदनुसार परिवर्तन करना होगा आप –

+0

मेरे उत्तर के साथ, @logray उत्तर भी जोड़ें ... यह –

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