2012-05-06 31 views
7

मेरे ऐप में ListView और EditText इसके नीचे बैठा है। किसी कारण से, टैब कुंजी onKeyListener को ट्रिगर नहीं करती है। मैं जिन सभी अन्य चाबियाँ प्रबंधित कर रहा हूं (DEL, ENTER, DPAD_UP/डाउन/सेंटर) ठीक है। मैंने dispatchKeyEvent में ब्रेकपॉइंट जोड़ा, फिर से कोई भी भाग्य घटनाओं को प्राप्त करने में भाग्य नहीं मिला।एडिटटेक्स्ट टैब कुंजी ईवेंट नहीं प्राप्त कर रहा है - स्टॉक सॉफ्ट वीके

मेरे ऐप में टेक्स्ट प्रदर्शित करने के लिए पहले TextView था और इस समय के दौरान, टीएबी कार्यक्रम ठीक हो गए थे। ListView ने अब TextView को बदल दिया है।

मैं पूरी तरह से रहस्यमय हूं कि टीएबी कार्यक्रम अब क्यों प्राप्त नहीं हुआ है। यह स्टॉक एक्सूम पर है, 2.3.6 के साथ आईसीएस 4.0.4 & स्टॉक एन 1 चला रहा है।

मैंने TextView का उपयोग कर संस्करण के विरुद्ध अपने वर्तमान कोड की तुलना की है और अधिकांश कोड TextView के स्थान पर ListView को संभालने के लिए है। nextFocusLeft और nextFocusRight विशेषताएँ के अलावा, संपादन टेक्स्ट के लिए और कुछ नहीं बदला है।

संपादित करें: मैंने अभी गो कीबोर्ड और हैकर कीबोर्ड के साथ प्रयास किया है और टैब ठीक है। ऐसा प्रतीत होता है कि यह कुछ वर्चुअल कीबोर्ड

उत्तर

0

मुझे लगता है कि मुझे समस्या दिखाई दे सकती है। ListView.java के स्रोत को देखते हुए, महत्वपूर्ण घटनाओं का उपभोग करने के लिए एक तंत्र है जो सूची आइटम के भीतर फ़ोकस को स्थानांतरित करता है। इस विधि से पहले टिप्पणियों के साथ-साथ विधि के बीच में टिप्पणियों के ब्लॉक को देखें।

/** 
* To avoid horizontal focus searches changing the selected item, we 
* manually focus search within the selected item (as applicable), and 
* prevent focus from jumping to something within another item. 
* @param direction one of {View.FOCUS_LEFT, View.FOCUS_RIGHT} 
* @return Whether this consumes the key event. 
*/ 
private boolean handleHorizontalFocusWithinListItem(int direction) { 
    if (direction != View.FOCUS_LEFT && direction != View.FOCUS_RIGHT) { 
     throw new IllegalArgumentException("direction must be one of" 
       + " {View.FOCUS_LEFT, View.FOCUS_RIGHT}"); 
    } 

    final int numChildren = getChildCount(); 
    if (mItemsCanFocus && numChildren > 0 && mSelectedPosition != INVALID_POSITION) { 
     final View selectedView = getSelectedView(); 
     if (selectedView != null && selectedView.hasFocus() && 
       selectedView instanceof ViewGroup) { 

      final View currentFocus = selectedView.findFocus(); 
      final View nextFocus = FocusFinder.getInstance().findNextFocus(
        (ViewGroup) selectedView, currentFocus, direction); 
      if (nextFocus != null) { 
       // do the math to get interesting rect in next focus' coordinates 
       currentFocus.getFocusedRect(mTempRect); 
       offsetDescendantRectToMyCoords(currentFocus, mTempRect); 
       offsetRectIntoDescendantCoords(nextFocus, mTempRect); 
       if (nextFocus.requestFocus(direction, mTempRect)) { 
        return true; 
       } 
      } 
      // we are blocking the key from being handled (by returning true) 
      // if the global result is going to be some other view within this 
      // list. this is to acheive the overall goal of having 
      // horizontal d-pad navigation remain in the current item. 
      final View globalNextFocus = FocusFinder.getInstance().findNextFocus(
        (ViewGroup) getRootView(), currentFocus, direction); 
      if (globalNextFocus != null) { 
       return isViewAncestorOf(globalNextFocus, this); 
      } 
     } 
    } 
    return false; 
} 

क्या एक सूची सूची में कई फोकस करने योग्य आइटम हैं? यदि ऐसा है, तो यह कोड टैब कुंजी का उपभोग करेगा। यदि ऐसा है, तो आप कुछ वस्तुओं को अयोग्य करने या किसी अन्य डिज़ाइन विकल्प पर विचार करना चाहेंगे।

+0

मैंने इसका परीक्षण करने के लिए एक परीक्षण प्रोजेक्ट स्थापित किया और दुर्भाग्यवश यह काम नहीं किया। संपादन में हमेशा ध्यान केंद्रित किया जाता है, इसलिए इसे हमेशा कुंजीपटल प्राप्त करना चाहिए, या कम से कम, इसे प्रेषण में पकड़ा जाना चाहिए। यह हैकर कीबोर्ड के साथ ठीक काम करता है लेकिन स्टॉक एक नहीं। मैंने यहां परीक्षण परियोजना अपलोड की है http://dl.dropbox.com/u/78755665/Test.zip सब कुछ सूची दृश्य –

+0

में गैर-केंद्रित करने के लिए सेट है, मैंने दो बार चेक किया है, यह निश्चित रूप से सही फ़ाइल है। –

+0

जब मैं इसे अपने सैमसंग गैलेक्सी एसआईआई एपिक 4 जी पर चलाता हूं, तो सॉफ्ट कीबोर्ड एक टैब कुंजी भी नहीं दिखाता है। –