Create listview with database data and place an EditText in front of each information

0

I need to create a listview within a dialog, using the data from the SQLite database, but in each of the data it is going to load, you have to have an EditText in front, for example.

Product Quantity EditText Fertilizer

    
asked by anonymous 25.10.2017 / 11:57

1 answer

1

After creating your listing normally (data and adapter), simply enter them in the dialog. Something like:

public class MyDialog extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

        View view = LayoutInflater.from(getActivity()).inflate(R.layout.my_list, null, false);

        // Listagem normal: recuperar ListView, dados do banco, criar adapter que terá seu próprio layout (com o EditText e os TextViews) para os dados

        alertDialogBuilder.setTitle("Título")
                .setMessage("Mensagem")
                .setView(view);
                  .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          //TODO
                      }
                  })
                  .setNegativeButton("Cancelar", null);

        return alertDialogBuilder.create();
    }

}
    
25.10.2017 / 12:21