Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Caused by: android.view.InflateException: Binary XML file line #42: Error inflating class fragment
- public class HoleListFragment extends Fragment {
- String KEY_ID = "_id";
- String KEY_HOLE = "hoyo";
- String KEY_PAR = "par";
- String KEY_HANDICAP = "handicap";
- String KEY_YARDS = "yardaje";
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
- DataBaseHelper myDbHelper = new DataBaseHelper(getActivity());
- try {
- myDbHelper.createDataBase();
- } catch (IOException ioe) {
- throw new Error("Unable to create database");
- }
- try {
- myDbHelper.openDataBase();
- }catch(SQLException sqle){
- throw sqle;
- }
- Cursor c = myDbHelper.getAllCourseContacts();
- if(c.moveToFirst())
- {
- do{
- HashMap<String, String> map = new HashMap<String, String>();
- map.put(KEY_HOLE, "Hoyo "+c.getString(1));
- map.put(KEY_PAR, "Par "+c.getString(2));
- map.put(KEY_HANDICAP,"Handicap "+ c.getString(3));
- map.put(KEY_YARDS,c.getString(4)+" yds.");
- menuItems.add(map);
- }while(c.moveToNext());
- }
- myDbHelper.close();
- GridView gridView = (GridView)getView().findViewById(R.id.gridView1); //<-- can´t get this view correctly
- ListAdapter adapter = new SimpleAdapter(getActivity(), menuItems,
- R.layout.list_item,
- new String[] { KEY_HOLE, KEY_PAR, KEY_HANDICAP, KEY_YARDS }, new int[] {
- R.id.hole, R.id.par, R.id.handicap,R.id.yards });
- gridView.setAdapter(adapter);
- }
- public View onCreateView(LayoutInflater inflater,
- ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.holelistfragment, container, false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement