Search in sources :

Example 1 with CustomAdapter_CategoriasI

use of layout.CustomAdapter_CategoriasI in project AdMoney by ErnestoGonAr.

the class CategoriasIngreso method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_categorias_ingreso);
    aceptar = (Button) findViewById(R.id.aceptarin);
    agregar = (ImageButton) findViewById(R.id.agregar_ci);
    bd = new BDHandlerAM(this);
    bandera = false;
    a = bd.spinneringresos();
    RecyclerView rv = (RecyclerView) findViewById(R.id.recycler_ci);
    try {
        String[][] dataSet = bd.obtenerCategoriasi();
        LinearLayoutManager ln = new LinearLayoutManager(this);
        ln.setOrientation(LinearLayoutManager.VERTICAL);
        CustomAdapter_CategoriasI adapter = new CustomAdapter_CategoriasI(dataSet);
        rv.setLayoutManager(ln);
        rv.setAdapter(adapter);
    } catch (ArrayIndexOutOfBoundsException e) {
        Toast toast = Toast.makeText(this, "No hay categorias de Ingresos", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        toast.show();
        return;
    }
    agregar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog.Builder mBuilder = new AlertDialog.Builder(CategoriasIngreso.this);
            View mView = getLayoutInflater().inflate(R.layout.insertar_categoriase, null);
            final EditText insertar = (EditText) mView.findViewById(R.id.insertb);
            final Button iguardar = (Button) mView.findViewById(R.id.insertarguardar);
            final Button icancelar = (Button) mView.findViewById(R.id.insertarcancelar);
            mBuilder.setView(mView);
            AlertDialog dialog = mBuilder.create();
            dialog.show();
            insertar.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(insertar, InputMethodManager.SHOW_IMPLICIT);
            iguardar.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    validartexto = insertar.getText().toString();
                    insertar();
                    if (bandera) {
                        bd.insertarCI(primeroMayuscula(insertar.getText().toString()), 7);
                    }
                    onBackPressed2();
                }
            });
            icancelar.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    onBackPressed2();
                }
            });
        }
    });
    aceptar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) InputMethodManager(android.view.inputmethod.InputMethodManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) Toast(android.widget.Toast) ImageButton(android.widget.ImageButton) Button(android.widget.Button) CustomAdapter_CategoriasI(layout.CustomAdapter_CategoriasI) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 ImageButton (android.widget.ImageButton)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 CustomAdapter_CategoriasI (layout.CustomAdapter_CategoriasI)1