2013-06-06 8 views
8

मैं चेतावनी मिलती है निर्दिष्ट नहीं है, जब मैं (नीचे) एक ट्यूटोरियल कोड की एक प्रति को संशोधितयह पाठ क्षेत्र एक inputType या एक संकेत

<EditText android:id="@+id/edit_message" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:hint="@string/edit_message" 
    android:layout_weight="1" /> 
"यह पाठ क्षेत्र एक inputType या एक संकेत निर्दिष्ट नहीं करता"

यह ठीक काम करता है, और चेतावनी केवल तभी आती है जब कोई नई रिक्त रेखा बनाई जाती है

मैंने इसे कई मित्रों के साथ संशोधित किया है जिसमें यह बताया गया है कि प्रत्येक भाग क्या करता है, जब भी मैं एक अतिरिक्त रेखा में जोड़ता हूं उपरोक्त में (यहां तक ​​कि एक खाली रेखा, इस मामले में यह एक टिप्पणी पंक्ति है) मुझे उपरोक्त त्रुटि

प्राप्त होती है
<!--edit text creates a text input box--> 
<EditText android:id="@+id/edit_message" 
<!-- edit_message is a variable, defined in strings.xml--> 
<!-- determines the width of the textField, in this case 0dp means "however long the text is" IE: it will grow to fit however many characters the user types --> 
    android:layout_width="0dp" 
<!-- determines the height of the Text Field --> 
    android:layout_height="wrap_content" 
<!-- The hint is the default value for the text field, it calls on the variable edit_message defined in strings.xml--> 
    android:hint="@string/edit_message" 
<!-- Weight means how much the screen the text field can take up, in this case, the ratio is 1:1 so it can take up however much room is needed, However if a different variable also had the weight of 1, the ratio would be 1:2 and each could take up half the screen --> 
    android:layout_weight="1" /> 

टिप्पणियों के बिना, चेतावनी वहाँ

+0

जहां तक ​​मुझे पता है, आप अपनी टिप्पणी xml तत्व को तोड़ नहीं सकते हैं। अर्थात। आप '' के बीच टिप्पणियां नहीं डाल सकते हैं। [एक समान सवाल] (http://stackoverflow.com/a/16904880/1029225), संयोग से उसी कोड स्निपेट के साथ, हाल ही में उत्तर दिया गया था। –

उत्तर

0

नहीं है मैं तो बस अपने कोड चलाने के लिए और मेरे ऐप ठीक से चल रहा है, जब मैं टिप्पणी यह ​​दुर्घटनाओं कहा, तो मैं महसूस किया कि आप अपनी XML अंदर टिप्पणी नहीं करना चाहिए, यह एक्सएमएल का एक सिद्धांत है।

मेरा सुझाव है कि आप इस लेख को पढ़ने के लिए सुझाव दें कि एक अच्छी तरह से गठित एक्सएमएल क्या है और सही तरीके से एक्सएमएल पर कैसे टिप्पणी करें http://webdesign.about.com/cs/xmlinformation/ht/htcommentxml.htm यहां भी इस विशेष विषय के बारे में चर्चा हुई है और इसे हल किया गया है।

https://stackoverflow.com/a/2073162/2069737

आशा है कि यह आप में मदद करता है।

1

तार्किक रूप से आपको लाइन <EditText android:id="@+id/edit_message" और अगली पंक्ति में एक त्रुटि में चेतावनी प्राप्त करनी चाहिए।

कारण:
जब आप टिप्पणी टैग दे रहे हैं, फिर टिप्पणी की बंद टैग EditText के लिए अवैध रूप से बंद टैग के रूप में माना जाता है। तो तुम भी निम्न त्रुटि

Element type "EditText" must be followed by either attribute specifications, ">" or "/>".

और उपरोक्त त्रुटि शेष कोड निष्पादित नहीं किया गया है की वजह से है और इस तरह आप एक चेतावनी

This text field does not specify an inputType or a hint 

भले ही android:hint विशेषता अपने कोड में मौजूद है मिलना चाहिए ।

18

इस चेतावनी का कारण यह है कि आपने इस संपादन टेक्स्ट के लिए इनपुट टाइप सेट नहीं किया है।

android:inputType="text" 

तो यह इस तरह दिखना चाहिए: निम्नलिखित पंक्ति जोड़

<EditText android:id="@+id/edit_message" 
    android:inputType="text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:hint="@string/edit_message" 
    android:layout_weight="1" /> 

और चेतावनी चला गया है।

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