Tuesday 15 June 2010

android - Context becomes null For griview embedded in a dialog -


I am trying to communicate showing the gallery of photos captured, but when it's running on tap on gv exception SetAdapter (new EOrderGalleryAdapter (getApplicationContext (data)); is

is there about to open pictures files located in the external SD card using the default There are hints or tutorials - Gallery or other?

Below is my code

  Last dialogue dialog = New message (GetBaseContext ()); // If you want to communicate, then remove the default title Denkvindofecr (window. FEATURE_NO_TITLE); // Here is where the Gridwu dialogue in our custom XML Kset Kantentwu (r. Lyaut . Gallery); string sdCardRootPath = Pryavarnkgetanstainstaurpolik directory (environment. DIRECTORY_DCIM) Kststring () + "/ Tivibi_ [PV_ photo" Root file = new file (Sdisiarararpath); file] picFiles = rootFolder.listFiles (); ArrayList & LT; B Tiemap> data = new arreelist & lt; Bitmap & gt; (); (File: picFiles) {// bitmap b = bitmapfile Decodefile (pic.getAbsolutePath ()); Bitmap b = decodfile (image, 4); Data.add (b); } GridView gv = (GridView) findViewById (R.id.grid_view); Gv.setAdapter (new EOrderGalleryAdapter (getApplicationContext (), data)); gv.setOnItemClickListener (New OnItemClickListener () {@Override public void onItemClick (AdapterView & LT ;? & gt; parents, see V, int position, long id) {// TODO Auto-generated method stub Toast.makeText (getBaseContext ( ), "Picture" + (position + 1) + "selected", toast.LnnGHIHORT). Show ();}});   

Logkat

  06-21 10: 19: 50.946: E / Android Random (3925): On Android. $ View.View $ 1.onClick (see Java: 3125) October 06-21: 19: 50.946: E / AndroidRuntime (3925): ... 11 and 06-21 October: 19: 50.946: E / AndroidRuntime (3925) ): Because of: java.lang.NullPointerException 06 -21 10: 1 9: 50.946: E / Android Random (3925): atvpv.test.OrderSystem1.EOSCustPayment.onCreateDialog (EOSCustPayment.java352) 06-21 10:19: 50.946: e / Androidrentaim (3 9 25): Android on .app.Activity.onCreateDialog (Activity.java:2828) 06-21 10: 19: 50.946: e / AndroidRuntime (3925): AndroidkappkActivitykcreateDialog ( Activity.java:944) on 06-21 10:19: 50.946: e / AndroidRuntime (3925): on android.app.Activity.showDialog (Activity.java:2921) 06-21 October: 19: 50.946: e / AndroidRuntime (3925): android.app.Activity.showDialog (Activity.java:2880) 06-21 October: 19: 50.946: / AndroidRuntime (3925): atvpv.test.OrderSystem1.EOSCustPayment.buttonGallery (EOSCustPayment.java:421)    

I do not think the problem is getApplicationContext () .

Reasonably tap pointers should be GV. As you are calling gv.setAdapter it therefore detects that GV is empty and throws an exception.

No comments:

Post a Comment