i tried fill listview data, app crashes every time.
the listview returns null time .
here fragment code
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { listview = (listview) getactivity().findviewbyid(r.id.list);strong text imageadapter imageadapter = new imageadapter(this.getactivity(), images); if(listview == null) toast.maketext(this.getactivity(),"nulll", toast.length_long).show(); return inflater.inflate(r.layout.fragment_poster, container, false); }
and here fragment layout
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <listview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight = "1" android:id="@+id/list"> </listview> </linearlayout>
because trying find activity... not fragment.
view rootview = inflater.inflate(r.layout.fragment_poster, container, false); listview = (listview) rootview.findviewbyid(r.id.list); imageadapter imageadapter = new imageadapter(getactivity(), images); listview.setadapter(imageadapter); return rootview;
Comments
Post a Comment