Ich habe versucht, eine ListView mit Daten zu füllen, aber die App stürzt jedes Mal ab.Warum gibt das ListView-Objekt jedes Mal null zurück?
Die ListView gibt die ganze Zeit Null zurück.
Hier ist mein 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);
}
Und hier ist mein 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>