2013-04-25 10 views
6

के बीच चल रहा है मेरे पास 2 टुकड़े हैं जिनमें कुछ संपादन टेक्स्ट बॉक्स हैं। वे दोनों समान हैं, हालांकि यह बहुत अजीब है कि 1 संपादन टेक्स्ट फ़ील्ड के बीच टैब होगा, लेकिन दूसरा नहीं होगा।एंड्रॉइड एक्सएमएल - एडिटटेक्स्ट फ़ील्ड्स

यह एक मैं के साथ समस्या आ रही है है:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/loginparent" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ff008DFF" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="20dip" 
     android:background="#ff008DFF" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="40dip" 
      android:contentDescription="@string/logoDesc" 
      android:src="@drawable/logo1" /> 

     <EditText 
      android:id="@+id/usernameLog" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:hint="@string/username" 
      android:imeOptions="actionNext" 
      android:singleLine="true" 
      android:textSize="14sp" /> 

     <EditText 
      android:id="@+id/passwordLog" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/password" 
      android:imeOptions="actionDone" 
      android:inputType="textPassword" 
      android:singleLine="true" 
      android:textSize="14sp" /> 

     <Button 
      android:id="@+id/loginButton" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/login" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dip" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:focusable="false" 
       android:focusableInTouchMode="false" 
       android:text="@string/newuser" 
       android:textColor="#ffffffff" 
       android:textSize="14sp" /> 

      <Button 
       android:id="@+id/viewSignupBtn" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/signup" /> 
     </LinearLayout> 
    </LinearLayout> 

    <ProgressBar 
     android:id="@+id/progressBarLog" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:padding="70dip" 
     android:visibility="gone" /> 

</RelativeLayout> 

जब मैं पहली बार EditText बॉक्स के टैब, ध्यान एक 2 टैब यह 2 क्षेत्र के लिए ध्यान केंद्रित करने से चलता है पर गायब हो जाता है तो। यदि मैं टैब फोकस चला जाता हूं तो फिर वही होगा, फिर टैब फिर से करें और यह नीचे दिए गए बटन पर दिखाई देता है।

फ़्रेगमेंट के ऑनक्रेट व्यू में कुछ भी विशेष नहीं है, पॉइंटर्स को संपादन टेक्स्ट फ़ील्ड में प्राप्त करने के अलावा। जैसे मैं कहता हूं, मेरे पास दूसरा दृश्य बहुत समान है जो ठीक काम करता है।

जब मैं टैब, मैं नोटिस मैं इन चेतावनियों Logcat में प्रदर्शित मिलती है:

04-24 19:31:29.695: D/InputEventConsistencyVerifier(2040): KeyEvent: ACTION_UP but key was not down. 
04-24 19:31:29.695: D/InputEventConsistencyVerifier(2040): in [email protected] 
04-24 19:31:29.695: D/InputEventConsistencyVerifier(2040): 0: sent at 4325570000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4325570, downTime=4325514, deviceId=0, source=0x101 } 
04-24 19:31:31.076: D/InputEventConsistencyVerifier(2040): KeyEvent: ACTION_UP but key was not down. 
04-24 19:31:31.076: D/InputEventConsistencyVerifier(2040): in [email protected] 
04-24 19:31:31.076: D/InputEventConsistencyVerifier(2040): 0: sent at 4326945000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4326945, downTime=4326889, deviceId=0, source=0x101 } 
04-24 19:31:32.255: D/InputEventConsistencyVerifier(2040): KeyEvent: ACTION_UP but key was not down. 
04-24 19:31:32.255: D/InputEventConsistencyVerifier(2040): in [email protected] 
04-24 19:31:32.255: D/InputEventConsistencyVerifier(2040): 0: sent at 4328123000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4328123, downTime=4328053, deviceId=0, source=0x101 } 

संपादित -----------------

ठीक है, टिप्पणियों में सुझाव दिया गया है, मैंने फोकस चेंज श्रोताओं को सभी विचारों में जोड़ा (उन सभी के माध्यम से लूप किया गया और श्रोता जोड़ा) और लॉग इन किया कि क्या दृश्य है। प्रत्येक बार जब मैं टैब प्राप्त करता हूं, मुझे लॉग मिलता है लेकिन अजीब बात यह है कि, मैं पहले संपादन टेक्स्ट बॉक्स में टैब करता हूं और लॉग कहता है कि संपादन टेक्स्ट बॉक्स पर ध्यान केंद्रित किया गया है, मैं फिर से टैब करता हूं और फोकस खो जाता है लेकिन लॉग कहता है कि वही संपादन टेक्स्ट बॉक्स फोकस करता है! टैब फिर से और दूसरा फोकस हो जाता है और लॉग सही आईडी कहता है, टैब फिर से खो गया है लेकिन फिर लॉग कहता है कि दूसरा संपादन टेक्स्ट बॉक्स फोकस है, भले ही यह नहीं है !!

बहुत अजीब व्यवहार।

+0

'android: focusableInTouchMode' समस्या हो सकती है? –

+0

मुझे डर नहीं है। EditText वैसे भी ध्यान केंद्रित योग्य है। – Darren

+0

क्या फ्रैगमेंट को जोड़ने के तरीके से कुछ करना पड़ सकता है? साथ ही, क्या यह संभवतः एक तरीका है कि यह पता लगाने का तरीका है कि जब यह ExitText बॉक्स से गायब हो जाता है तो फोकस क्या हो रहा है? – Darren

उत्तर

4

जैसा कि @Delyan सुझाव देता है, आप इस व्यवहार को नियंत्रित करने के लिए एक XML विशेषता जोड़ने में सक्षम होना चाहिए। हालांकि, आप android:nextFocusForward जैसे अन्य android:nextFocus____ विशेषताओं में से किसी एक का उपयोग करने का प्रयास करना चाह सकते हैं। इन विशेषताओं की एक पूरी सूची here और नीचे उपलब्ध है।

+0

'एंड्रॉइड: अगला फोकस फॉरवर्ड 'काम करता है :-) बहुत बहुत धन्यवाद। मुझे उस बारे में पता नहीं था, लेकिन यह दिखाने के लिए दृश्य को इंगित करता है, और यह काम करता है। धन्यवाद – Darren

+0

@ डेरेन, आपका स्वागत है! खुशी है कि मैं मदद कर सकता था। – Phil

+0

इसके अलावा, अगर यह प्रश्न का उत्तर देता है, तो कृपया स्वीकार करना न भूलें :) – Phil

1

आप टैब आदेश को ओवरराइड करने के लिए android:nextFocusDown का उपयोग कर सकते हैं। आम तौर पर, टैब नीचे दिखता है, शिफ्ट + टैब दिखता है और दिशात्मक कुंजी/ट्रैकबॉल बाएं/दाएं फोकस लुकअप को ट्रिगर करता है।

+0

धन्यवाद। मैंने 'android: nextFocusDown =" @ + id/passwordLog "जोड़ने की कोशिश की है, लेकिन मुझे 2 टैब की आवश्यकता के समान व्यवहार मिलता है। – Darren

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