Create listview with database data and put an Edittext in front of each information

Asked

Viewed 291 times

0

I need to create a listview inside a dialog, using the data of the Sqlite database, but in each of the data that will load has to have an Edittext in front, for example.

Product Quantity Adubo Edittext

1 answer

1


After creating your list normally (data and Adapter), just insert them into 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();
    }

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.