Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 5th, 2013  |  syntax: None  |  size: 1.90 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Caused by: android.view.InflateException: Binary XML file line #42: Error inflating class fragment
  2.        
  3. public class HoleListFragment extends Fragment  {
  4.  
  5. String KEY_ID = "_id";
  6. String KEY_HOLE = "hoyo";
  7. String KEY_PAR = "par";
  8. String KEY_HANDICAP = "handicap";
  9. String KEY_YARDS = "yardaje";
  10.  
  11.  @Override
  12.  
  13. public void onCreate(Bundle savedInstanceState) {
  14.  
  15.      super.onCreate(savedInstanceState);
  16.      ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
  17.      DataBaseHelper myDbHelper = new DataBaseHelper(getActivity());
  18.      try {
  19.  
  20.          myDbHelper.createDataBase();
  21.  
  22.      } catch (IOException ioe) {
  23.  
  24.          throw new Error("Unable to create database");
  25.  
  26.      }
  27.  
  28.      try {
  29.  
  30.          myDbHelper.openDataBase();
  31.  
  32.      }catch(SQLException sqle){
  33.  
  34.          throw sqle;
  35.  
  36.      }
  37.  
  38.      Cursor c = myDbHelper.getAllCourseContacts();
  39.      if(c.moveToFirst())
  40.      {
  41.          do{
  42.              HashMap<String, String> map = new HashMap<String, String>();
  43.              map.put(KEY_HOLE, "Hoyo "+c.getString(1));
  44.              map.put(KEY_PAR, "Par "+c.getString(2));
  45.              map.put(KEY_HANDICAP,"Handicap "+ c.getString(3));
  46.              map.put(KEY_YARDS,c.getString(4)+" yds.");
  47.  
  48.  
  49.              menuItems.add(map);
  50.          }while(c.moveToNext());
  51.      }  
  52.      myDbHelper.close();
  53.      GridView gridView = (GridView)getView().findViewById(R.id.gridView1); //<-- canĀ“t get this view correctly
  54.      ListAdapter adapter = new SimpleAdapter(getActivity(), menuItems,
  55.                 R.layout.list_item,
  56.                 new String[] { KEY_HOLE, KEY_PAR, KEY_HANDICAP, KEY_YARDS }, new int[] {
  57.                         R.id.hole, R.id.par, R.id.handicap,R.id.yards });
  58.  
  59.  
  60.     gridView.setAdapter(adapter);
  61.  
  62.  
  63.  }
  64.  
  65.  
  66.  public View onCreateView(LayoutInflater inflater,
  67.          ViewGroup container, Bundle savedInstanceState) {
  68.             return inflater.inflate(R.layout.holelistfragment, container, false);
  69.  
  70.  }
clone this paste RAW Paste Data