java - NullPointerException on onPostExecute method -


I get a navigation drawer for my app that has a menu with which I can navigate between the pieces. The first piece that comes after the apple luncheon is the home in which there is a list view and an attached footprint on the bottom (only for testing). The problem occurs when I do not have a home piece lunch for the first time and used to do its job very well, but when I change the piece from the navigation drawer and trying to bring the piece of house back to the app crash . Error log shows me a null pointer exception. This is my code description

onCreateView method

  @ override public View Creatives (LayoutEflettter Inflator, View Group Container, Bundle Saved InstantState) {if (v! = Null) {ViewGroup parent = (ViewGroup) v.getParent (); If (parents! = Zero) parents .removeView (v); } Try {V = inflater.inflate (R.layout.fragment_homes, container, false); ListView = (list view) v.findViewById (R.id.homeList); L = New HomeList Adapter (this, home list); If (L == empty) Log.i ("tag", "tap"); ListView.setAdapter (L); } Hold (InflateException E) {} Return V; } PostOxecute (Ultimate String Res) {0} on Override Protected Zero   

onPostExecute method

 / * Try {jObj = New JSONArray (res); } Hold (JasonX Express E) {e.printStackTrace (); } * / / * JSONArray j = faucet; Try {j = New JSONArray (res); } Hold (JasonX Express E) {e.printStackTrace (); } * / / For parsing json (int i = 0; i   

Error log

  10-10 09: 31: 30.884 2447-2447 / com.example.user. Unchained E / Android Time ?? Fatal exception: main process: com.example.user.unchained, pid: 2447 com.example.user.unchained.HomesActivity $ PlaceholderFragment $ FeedsTask.onPostExecute (HomesActivity.java:375) at java.lang.NullPointerException. Android.os.AsyncTask.access $ 600 (asyncTask.java:177) at user.unchained.HomesActivity $ PlaceholderFragment $ FeedsTask.onPostExecute (HomesActivity.java:277) android.os.AsyncTask.finish (AsyncTask.java:632) Android.os.Looper.loop on android.os.AsyncTask $ InternalHandler.handleMessage (AsyncTask.java:645) android.os.andandroid.app.andandroid.app at Handler.dispatchMessage (Handler.java:102) At .ActivityThread.main (ActivityThread.java ** 017) com.android.internal.os at java.lang.reflect.Method.invokeNative java.lang.reflect.Method.invoke (Method.java +15) on dalvik.system.NativeStart.main (Native method)   and this is the EXA line due to Ctly error:  l.notifyData SetChanged (); . I have seen that the error is in the case when I am trying to display a piece of seconds.  

Any help please? Thanks!

You need to use this in doInBackground.

  @ Override protected void doInBackground (zero ...) {try {(int i = 0; i & LT; 5; i ++) of {// JSONObject obj = j for. GetJSONObject (i); Home Home = New Home (); // string photoNews = java.net.URLDecoder.decode (obj.getString ("photonews"), "UTF-8"); Home.setNomC ("Karim Annasiri"); Home.setPhotoP ("http://i1239.photobucket.com/albums/ff509/FestusMANAFEST/iker-casillas20Wallpaper__yvt2.jpg"); Home.setPhotoAr ("http://voyage-essaouira-maroc.com/upload/apostrophe_image_(13).jpg"); Home.setText ("Chlada v 2.0 version"); // in home.java settext for some other names in the gator setter. It does not understand whether you are using setText for textview or not. Home.setNbrSick ("5"); Home.setNbrComm ("8"); Home.setNbrShare ("0"); HomeList.add (home); }   

postExecute is used to display the UI. Do not perform heavy operations such as parsing in PostExecute.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -