i am having thsi error that i don't know why is happening and i hope you can help me. I am loading a gridview, that is composed by a couple of networkImageView. I've created a customGridViewAdapter, which i send a List imagesUrls and it downloads this images inside the networkImageViews. well, at this case, the list of url that i am sending has 10 elements. When the adapter load these 10 networkImageView there is no problem, actually it works, but i don't know why, the adapter keeps executing two more times (at this time, it takes the position 0 of the url's list). So, i am having this error
11-16 20:07:03.575: E/AndroidRuntime(6142): FATAL EXCEPTION: main
11-16 20:07:03.575: E/AndroidRuntime(6142): java.lang.NullPointerException
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.GridView.setupChild(GridView.java:1373)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.GridView.makeAndAddView(GridView.java:1341)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.GridView.makeRow(GridView.java:343)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.GridView.fillDown(GridView.java:285)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.GridView.fillFromTop(GridView.java:418)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.GridView.layoutChildren(GridView.java:1230)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.AbsListView.onLayout(AbsListView.java:1873)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.view.View.layout(View.java:11444)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.view.ViewGroup.layout(ViewGroup.java:4331)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.view.View.layout(View.java:11444)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.view.ViewGroup.layout(ViewGroup.java:4331)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1666)
11-16 20:07:03.575: E/AndroidRuntime(6142): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1524)
this is the part of the adapter that download the images:
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
String imageUrlSelected = imagesUrl.get(position);
View vi=convertView;
RecordHolder holder;
if(convertView==null){
vi = inflater.inflate(R.layout.row_grid_fotos_elemento, null);
holder = new RecordHolder();
holder.networkImageView = (NetworkImageView) vi.findViewById(R.id.niv_large);
if (imagen != null) {
holder.networkImageView.setImageUrl(imageUrlSelected, imageLoader);
} else {
}
}
return vi;
}
public class RecordHolder {
NetworkImageView networkImageView;
}
when i debug step by step i can see that at a point the images load successfully, but, how i said before, it keeps executing.
i would appreciate your help!
This may be too late to help. But usually Nullpointer Exceptions
with Volley stem from not declaring the custom application class in your manifest. If this step isn't done, then your volley application singleton doesn't initialize because its onCreate
doesnt get called.
So you should have something like this in your manifest
<application
android:name="ImgController" <--your volley singleton that extends Application
android:allowBackup="true"
android:label="@string/app_name">`