Beispiel #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            int rows, columns;
            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            if (preferences.GetString("Rows", "").Equals(""))
            {
                rows = 9;
            }
            else
            {
                rows = int.Parse(preferences.GetString("Rows", "").ToString());
            }

            if (preferences.GetString("Columns", "").Equals(""))
            {
                columns = 9;
            }
            else
            {
                columns = int.Parse(preferences.GetString("Columns", "").ToString());
            }

            View rootView = inflater.Inflate(Resource.Layout.FragmentoBotonera, container, false);
            //Layout botonera se encarga de crear el layout vacío principal done van los botones
            LayoutBotonera layoutBotonera = new LayoutBotonera();

            rootView = layoutBotonera.rootView(rows, columns);
            switch (tipoTeclado)
            {
            case "principal":
                List <Boton> botonesPrincipal = configuracionTeclado.GetBotones(teclados, "principal");
                List <Boton> functionButtons  = configuracionTeclado.GetBotones(teclados, "funciones");
                layoutBotonera.CrearBotonera(layoutBotonera.layouts, botonesPrincipal, 0, botonesPrincipal.Count, Resources);
                layoutBotonera.CrearBotonera(layoutBotonera.layouts, functionButtons, columns * (rows - 1) + 1, rows * columns, Resources);
                AsignarFuncionesABotones(botonesPrincipal);
                AsignarFuncionesABotones(functionButtons);
                break;

            case "tecladoPagos":
                List <Boton> botonesPago = configuracionTeclado.GetBotones(teclados, "tecladoPagos");
                layoutBotonera.CrearBotonera(layoutBotonera.layouts, botonesPago, columns * (rows - 1) + 1, rows * columns, Resources);
                AsignarFuncionesABotones(botonesPago);
                break;
            }
            if (tipoTeclado.Contains("Categoria"))
            {
                List <Boton> botones            = configuracionTeclado.GetBotones(teclados, "tecladoCat");
                List <Boton> botonesDeCategoria = new List <Boton>();
                //Los botones que se necesitan obtener son aquellos que pertenecen a la categoría dada
                //por ejemplo: Categoría1, se necesitan escoger los botones que pertenecen a tecladoCat, y los
                //botones que pertenecen a Categoría1. La variable tipoTeclado poseé el nombre de la categoria
                foreach (Boton boton in botones)
                {
                    if (boton.getCategorias().Equals(tipoTeclado))
                    {
                        botonesDeCategoria.Add(boton);
                    }
                }

                layoutBotonera.CrearBotonera(layoutBotonera.layouts, botonesDeCategoria, 0, botonesDeCategoria.Count, Resources);
                AsignarFuncionesABotones(botonesDeCategoria);
            }
            return(rootView);
        }