android - I call a method in class A and from class it works. But if I call the same method in class B I get error -


यहां विधि है

  सार्वजनिक स्ट्रिंग testFile (int Numofpunches, स्ट्रिंग फाइलनाम, इंट चित्र, इंट रद्दपिक्स) {स्ट्रिंग स्ट्रिंग = ""; बूलियन ए; FILENAME = फाइलनाम; {FileInputStream fis = openFileInput (फाइलनाम) का प्रयास करें; कोशिश {इंट काउंटर = एफआईएस.रेड (एमआईआईडी, 0, एनएमफपन्चे); fis.close (); Int i = 0; जबकि (i & lt; काउंटर) {if (mIds [i] == 'c') {mTHhumbIds [i ++] = तस्वीर; //R.drawable.crab; स्ट्रिंग = string.concat ( "सी"); } अन्य {एमटीहम्बइड्स [आई] = रद्द करें; स्ट्रिंग = string.concat ( "एक्स"); इमेजिव्यू पेंचिट = (इमेजव्यू) ढूंढिए वीवीआईबीआईआईडी (माइपुनें [आई ++]); punchit.setImageResource (R.drawable.punchboxcancelled); }} स्ट्रिंग टेस्टफोर्डोन = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; A = string.equals (testfordone.substring (0, numofpunches)); यदि (ए) {वापसी "किया"; }} पकड़ (IOException ई) {}} पकड़ (FileNotFoundException ई) {try {// प्रारंभ स्ट्रिंग FILENAME = filename; FileOutputStream fos = openFileOutput (FILENAME, प्रसंग। MODE_PRIVATE); स्ट्रिंग = "cccccccccccccccccccccccccccccccccccccccccccccccccccccccc"; string.substring (0, numofpunches); कोशिश {fos.write (string.getBytes ()); fos.close (); इंट काउंटर = 0; जबकि (काउंटर & lt; numofpunches) {mThumbIds [काउंटर ++] = तस्वीर; }} पकड़ (IOException गलती) {}} पकड़ (FileNotFoundException त्रुटि) {}; }   

मैं इसे उसी कक्षा (ए) से कहता हूं जहां यह विधि स्थित है। अब मैं एक ही विधि के साथ एक नया वर्ग (पंच क्रियान्वयन) बना रहा हूं। आयात क्लास पंच एक्टिवेटिटीज़ में ए कॉल को विधि के रूप में

  पंच क्रियाविधिएं पीए = नया पंच क्रियान्वयन (); स्ट्रिंग परिणाम = pa.testFile (सभी आवश्यक पैरामीटर);   

रनटाइम पर प्रोग्राम को

  FileInputStream fis = openFileInput (फ़ाइलनाम) पर जाता है; पंच एक्टिवेटिटी में   

लेकिन फिर यह NullPointer त्रुटि के साथ क्लास ए में वापस हो जाता है क्यूं कर????? कोई भी एंड्रॉइड के नियमों को जानता है ??

मुझे लगता है कि समस्या इस पंक्ति में है: <पूर्व> punchit.setImageResource (R.drawable.punchboxcancelled);

इस वर्ग में, आपने पहले क्लास के रूप में उसी XML को सेट नहीं किया है (setContentView () विधि में onCreate ()) में। तो यह दृश्य यहां नहीं मिल सकता है।

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -