Skip to content Skip to sidebar Skip to footer

After Copying The Imageadapter To Fragment, Image Is Not Displaying

the Image not showing in the List adapter can you help me please? in the log cat I am having this last message , it means I am getting the http result, however the adapter is not w

Solution 1:

The problem with your code. that you call downloadMethod inside Fragment onCreate() but you should do it inside the onActivityCreated() as stated in the source code

  onCreated() can be called while the fragment's activity is
 * still in the process of being created.  As such, you can not rely
 * on things like the activity's content view hierarchy being initialized
 * at this point.  If you want to do work once the activity itself is
 * created, see {@link#onActivityCreated(Bundle)}.

So here we go

publicvoidonActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
     downloadImage();
}

Also You made a mistake in onCreateView : It should return the view you inflated

E.g it should look like as follows

@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragmentfinalViewv= inflater.inflate(R.layout.latestjokesfrag, container, false);
        list = (ListView) v.findViewById(R.id.ListView);

        return v;
    }

Post a Comment for "After Copying The Imageadapter To Fragment, Image Is Not Displaying"