2013-05-19 8 views
5

से मेल खाता है मेरी लेआउट इस कोडत्रुटि: कोई संसाधन में पाया गया कि इस फाइल में दिए गए नाम के

error: Error: No resource found that matches the given name (at 'id' with value '@id/question_text_view'). 
error: Error: No resource found that matches the given name (at 'id' with value '@id/next_button'). 

में निम्न त्रुटियों को प्रदर्शित कर रहे हैं इस लेआउट फ़ाइल

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@id/question_text_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="24dp" 
     /> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:orientation="horizontal" > 
     <Button 
      android:id="@+id/true_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/true_button" 
     /> 
     <Button 
      android:id="@+id/false_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/false_button" 
     /> 
    </LinearLayout> 
     <Button 
     android:id="@id/next_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/next_button" 
     /> 
</LinearLayout> 

यह मेरा तार है। xml

<?xml version="1.0" encoding="utf-8"?> 
    <resources> 

     <string name="app_name">GeoQuiz</string> 
     <string name="true_button">True</string> 
     <string name="false_button">False</string> 
     <string name="correct_toast">Correct</string> 
     <string name="next_button">Next</string> 
     <string name="incorrect_toast">Incorrect</string> 
    <string name="action_settings">Settings</string> 
    <string name="question_founder">Frank Reed Horton Founded APO on december 25 1947</string> 
    <string name="question_chief">Willy Wonka was known as a cheif</string> 
    <string name="question_lady">The first lady that became president in APO was Mary Katz</string> 
    <string name="question_president">Our current President of the Delta Rho chapter is john dolan</string> 
<string name="question_alphabets">Alpha, Beta, Gamma, Delta, Epsilon, Eta, Zeta</string> 
</resources> 

मुझे पता है कि तारों पर question_text_view पता है लेकिन मैंने अपनी गतिविधि में एक सरणी बनाई है जो सभी प्रश्न mQuestionTextView = (TextView) findViewById (R.id.question_text_view) लेता है; int प्रश्न = mQuestionBank [mCurrentIndex] .getQuestion(); mQuestionTextView.setText (प्रश्न); mQuestionBank सभी सवालों कि मैं getQuestion पूछना() की एक सरणी सवाल

और next_button मुझे नहीं पता है कि मैं गलत किया था के बाद से मैं strings.xml पर इसे शामिल करने के लिए दूसरा त्रुटि प्राप्त करने के लिए मेरी गेटर तरीका है क्या कोई मेरी मदद कर सकता है

+1

एंड्रॉयड: आईडी =" @ आईडी/question_text_view "होना चाहिए एंड्रॉयड: आईडी =" @ + id/question_text_view "बटन एंड्रॉयड के लिए एक ही : id = "@ + id/next_button" – Raghunandan

+1

कृपया देखें [अधिक संसाधन प्रकार] (एच ttp: //developer.android.com/guide/topics/resources/more-resources.html#Id) xml में दृश्यों के लिए आईडी को परिभाषित करने के लिए। ids में strings.xml फ़ाइल में रखने के लिए आपको '' ' 'के बजाय उपयोग करने की आवश्यकता होगी या आप इसके लिए अलग फ़ाइल बना सकते हैं जैसे ids.xml –

उत्तर

7

एंड्रॉयड: आईडी = "@ आईडी/question_text_view" होना चाहिए एंड्रॉयड: आईडी = "@ + id/question_text_view" बटन एंड्रॉयड के लिए एक ही: आईडी = "@ आईडी/next_button" एंड्रॉयड होना चाहिए: id = "@ + id/next_button"

TextView

<TextView 
    android:id="@+id/question_text_view" // missing + in your xml code 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="24dp" 
    /> 

बटन

<Button 
    android:id="@+id/next_button" // missing + in your xml code 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/next_button" 
    /> 

आईडी

किसी भी व्यू ऑब्जेक्ट में पेड़ के भीतर दृश्य को विशिष्ट रूप से पहचानने के लिए इसके साथ एक पूर्णांक आईडी हो सकती है। जब एप्लिकेशन संकलित किया जाता है, तो इस आईडी को पूर्णांक के रूप में संदर्भित किया जाता है, लेकिन आईडी को आम तौर पर लेआउट XML फ़ाइल में स्ट्रिंग के रूप में आईडी विशेषता में असाइन किया जाता है। यह एक एक्सएमएल विशेषता है जो सभी व्यू ऑब्जेक्ट्स (व्यू क्लास द्वारा परिभाषित) के लिए आम है और आप इसे अक्सर इस्तेमाल करेंगे। एक एक्सएमएल टैग के अंदर एक आईडी के लिए सिंटैक्स है:

स्ट्रिंग की शुरुआत में एट-प्रतीक (@) इंगित करता है कि एक्सएमएल पार्सर को शेष आईडी स्ट्रिंग को पार्स और विस्तार करना चाहिए और उसे पहचानना चाहिए आईडी संसाधन प्लस-प्रतीक (+) का अर्थ है कि यह एक नया संसाधन नाम है जिसे हमारे संसाधनों (आरजेवा फ़ाइल में) में बनाया और जोड़ा जाना चाहिए।

आपके मामले में बटन की विचार आईडी एंड्रॉइड के रूप में है: id = "@ id/next_button"। आप एंड्रॉइड संसाधन आईडी (मानते हैं) का संदर्भ दे रहे हैं। यह अस्तित्व में नहीं है। यह टेक्स्टव्यू के लिए भी वही है। इसलिए आपको संसाधन मिल गया त्रुटि नहीं मिली।

अधिक जानकारी के लिए नीचे दिए गए

http://developer.android.com/guide/topics/ui/declaring-layout.html

0

आपको आईडी के विचारों से सावधान रहना चाहिए। अपने टेक्स्ट व्यू में और आपके बटन दृश्य में आप आईडी विशेषता में '+' को भूल रहे हैं। जहां तक ​​मुझे पता है कि आप आईडी के साथ किसी अन्य दृश्य को संदर्भित करने का प्रयास करते हैं। यदि आप '+' का उपयोग कर रहे हैं तो आप उस दृश्य के लिए एक नई आईडी बनाते हैं।

फिक्स्ड संस्करण:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/question_text_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="24dp" 
     /> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:orientation="horizontal" > 
     <Button 
      android:id="@+id/true_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/true_button" 
     /> 
     <Button 
      android:id="@+id/false_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/false_button" 
     /> 
    </LinearLayout> 
     <Button 
     android:id="@+id/next_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/next_button" 
     /> 
</LinearLayout> 
0

लिंक की जाँच हो सकता है फ़ोल्डर पथ इस तरह मेरा "ई के रूप में बहुत लंबा है: \ 2.3 \ परियोजना \ मोबाइल \ SixworldGit \ sixworld \ परियोजनाओं \ sixworld \ SW_Vietnam। 2.0.20160711_Android_MoboSDKAll_lucgioi_20160711_1805 \ 2.3.2.0.20160711_Android_MoboSDKAll \ MoboSDK \ संदर्भ \ MoboSDKAll \ रेस \ drawable "

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

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