mercredi 12 août 2015

how to display gridview fragment from sqlite database

i have sqlite database and i will display into gridview fragment

when running this app i getting force close

this is my class GridV.java

public class GridV extends Fragment {

private DBDataSource dataSource;

private ArrayList<Barang> values;
public GridV(){}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

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

    dataSource = new DBDataSource(getActivity());
    dataSource.open();
    values = dataSource.getAllBarang();
    GridView gv = (GridView) rootView.findViewById(R.id.gridV);
    gv.setAdapter(new CustomGridAdapter(getActivity(), values));
    return rootView;
}

Aucun commentaire:

Enregistrer un commentaire