2012-04-18 12 views
5

एंड्रॉइड 1.6 (4) और 2.3.3 (10) के साथ परीक्षण किया गया।एंड्रॉइड एडिटटेक्स्ट इनपुट टाइप = "कोई नहीं" काम नहीं करता है, "textMultiLine" बन जाता है

मैं एक minimalistic परीक्षण आवेदन इस प्रदर्शन करने के लिए बनाया है, सब यह होता है के साथ एक्सएमएल लोड है:

setContentView(R.layout.main); 

और xml है:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:inputType="none" 
    android:ems="10" > 

</EditText> 

समस्या :

inputType="none" को निष्पादन के दौरान वास्तविक इनपुट प्रकार सेट करते समय textMultiLine(0x00020001) आता है, मैंने इसे डीबगर के साथ चेक किया है।

दूसरी ओर यदि मैं inputType="text" का उपयोग करता हूं तो यह अपेक्षा के अनुसार काम करता है।

क्या यह एंड्रॉइड में एक बग है?

उत्तर

12

मैं एक ही समस्या थी: एक्सएमएल के माध्यम से इनपुट प्रकार काम नहीं किया परिभाषित करने।

@Override 
public void onActivityCreated(@Nullable Bundle savedInstanceState) 
    { 
    ... 
    editText1= (EditText) super.getActivity().findViewById(R.id.editText1); 
    editText1.setInputType(InputType.TYPE_NULL); // none... 
    ... 
    } 

वह मेरे लिए काम करता है:

फिर, यह तय करने के लिए, मैं इनपुट प्रकार प्रोग्राम के लिए सेट करें।

+4

बेहतर 'उपयोग करने के लिए setInputType (InputType.TYPE_NULL)' –

2

मैं जो कह सकता हूं उससे एंड्रॉइड कोड में एक बग है। refrence के लिए यह देखने - How to make EditText not editable through XML in Android?

GalDude33 suggests-

android:clickable="false" 
    android:cursorVisible="false" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
1

उपयोग android:editable="false"। भले ही इसे बहिष्कृत किया गया हो, यह तब काम करता है जब इनपुट टाइप नहीं करता है।

1

उपयोग इस

textView.setKeyListener(null); 
1

इनपुट टाइप टाइप करना = "कोई नहीं" xml काम नहीं करता है, लेकिन यदि आप डाटाबेसिंग का उपयोग कर रहे हैं तो आप इनपुट प्रकार सेट करने के लिए बाध्यकारी वाक्यविन्यास का उपयोग कर सकते हैं।

आयात प्रकार ..

<data> <import type="android.text.InputType" /> </data>

तो बाँध मूल्य

<EditText android:id="@+id/edit_text" android:inputType="@{InputType.TYPE_NULL}" />

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