@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    llView = (LinearLayout)inflater.inflate(R.layout.fragment_layers, container, false);
    llView.findViewById(R.id.btnAddStrokeLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Layer newLayer = new StrokePL();
        createLayer(((IDd<ID>)mTree).getId(), newLayer);
      }
    });
    llView.findViewById(R.id.btnAddGroupLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Layer newLayer = new GroupLayer();
        createLayer(((IDd<ID>)mTree).getId(), newLayer);
      }
    });
    llView.findViewById(R.id.btnAddOtherLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        //TODO This will need to change, for settings, etc.
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        List<Class> classes = new ArrayList<Class>();
        try {
          classes = ClassScanner.getConcreteDescendants(getContext(), Layer.class, null);
        } catch (NoSuchMethodException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        }
        classes.remove(UACanvas.class);
        ArrayList<String> classNames = new ArrayList<String>();
        for (Class<?> clazz : classes) {
          classNames.add(clazz.getName());
        }
        String[] layerTypes = new String[]{};
        layerTypes = classNames.toArray(layerTypes);
        final List<Class> fClasses = classes;
        builder.setTitle("Pick a layer type")
                .setItems(layerTypes, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    try {
                      Layer newLayer = (Layer)fClasses.get(which).newInstance();
                      createLayer(((IDd<ID>)mTree).getId(), newLayer);
                    } catch (java.lang.InstantiationException e) {
                      e.printStackTrace();
                      showToast("Error creating layer:\n" + e.getMessage());
                    } catch (IllegalAccessException e) {
                      e.printStackTrace();
                      showToast("Error creating layer:\n" + e.getMessage());
                    }
                  }
                });
        builder.show();
      }
    });
    updateView();
    return llView;
  }
@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   
    llView = (LinearLayout)inflater.inflate(R.layout.fragment_layers, container, false);
    llView.findViewById(R.id.btnAddStrokeLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Layer newLayer = new StrokePL();
        createLayer(((IDd<ID>)mTree).getId(), newLayer);
      }
    });
    llView.findViewById(R.id.btnAddGroupLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Layer newLayer = new GroupLayer();
        createLayer(((IDd<ID>)mTree).getId(), newLayer);
      }
    });
    llView.findViewById(R.id.btnAddOtherLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
       
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        List<Class> classes = new ArrayList<Class>();
        try {
          classes = ClassScanner.getConcreteDescendants(getContext(), Layer.class, null);
        } catch (NoSuchMethodException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        }
        classes.remove(UACanvas.class);
        ArrayList<String> classNames = new ArrayList<String>();
        for (Class<?> clazz : classes) {
          classNames.add(clazz.getName());
        }
        String[] layerTypes = new String[]{};
        layerTypes = classNames.toArray(layerTypes);
        final List<Class> fClasses = classes;
        builder.setTitle("Pick a layer type")
                .setItems(layerTypes, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    try {
                      Layer newLayer = (Layer)fClasses.get(which).newInstance();
                      createLayer(((IDd<ID>)mTree).getId(), newLayer);
                    } catch (java.lang.InstantiationException e) {
                      e.printStackTrace();
                      showToast("Error creating layer:\n" + e.getMessage());
                    } catch (IllegalAccessException e) {
                      e.printStackTrace();
                      showToast("Error creating layer:\n" + e.getMessage());
                    }
                  }
                });
        builder.show();
      }
    });
    updateView();
    return llView;
  }
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { llview = (linearlayout)inflater.inflate(r.layout.fragment_layers, container, false); llview.findviewbyid(r.id.btnaddstrokelayer).setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { layer newlayer = new strokepl(); createlayer(((idd<id>)mtree).getid(), newlayer); } }); llview.findviewbyid(r.id.btnaddgrouplayer).setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { layer newlayer = new grouplayer(); createlayer(((idd<id>)mtree).getid(), newlayer); } }); llview.findviewbyid(r.id.btnaddotherlayer).setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { alertdialog.builder builder = new alertdialog.builder(getactivity()); list<class> classes = new arraylist<class>(); try { classes = classscanner.getconcretedescendants(getcontext(), layer.class, null); } catch (nosuchmethodexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } catch (classnotfoundexception e) { e.printstacktrace(); } classes.remove(uacanvas.class); arraylist<string> classnames = new arraylist<string>(); for (class<?> clazz : classes) { classnames.add(clazz.getname()); } string[] layertypes = new string[]{}; layertypes = classnames.toarray(layertypes); final list<class> fclasses = classes; builder.settitle("pick a layer type") .setitems(layertypes, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { try { layer newlayer = (layer)fclasses.get(which).newinstance(); createlayer(((idd<id>)mtree).getid(), newlayer); } catch (java.lang.instantiationexception e) { e.printstacktrace(); showtoast("error creating layer:\n" + e.getmessage()); } catch (illegalaccessexception e) { e.printstacktrace(); showtoast("error creating layer:\n" + e.getmessage()); } } }); builder.show(); } }); updateview(); return llview; }