lundi 25 mai 2015

Populating a ListView with random data

Here is my fragment's onCreateView : `

    String[] pelda = {
            "12345",
            "blabla",
            "hhahho",
    };

    List<String> elorejelzes = new ArrayList<String>(Arrays.asList(pelda));
     elorejelzesAdapter = new ArrayAdapter<String>(getActivity(),
            R.layout.lista_elem_elorejelzes,
            R.id.lista_elem_elorejelzes_textview,
             elorejelzes);

    View rootView = inflater.inflate(R.layout.fragment_idojaras_kijelzo, container, false);

    ListView listView = (ListView) rootView.findViewById(R.id.listView);
    listView.setAdapter(elorejelzesAdapter);
    return inflater.inflate(R.layout.fragment_idojaras_kijelzo, container, false);

I don't get any errors, I also verified, and the Activity starts the fragment correctly.

Here is my fragment XML code:

fragment_idojaras_kijelzo

<ListView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/listView"
    android:layout_gravity="center_horizontal|top" />

Aucun commentaire:

Enregistrer un commentaire