cgpa2.17
cgpa2.17

Reputation: 319

Formatting in android dialog

If in java console it's easy just use printf, but I'm new to android, how to create column to align those strings inside the dialog?

example :

public void onAlert() {
        new AlertDialog.Builder(MainActivity.this)
        .setTitle("Completed! Workout log: ")
                .setMessage("Date: " + date + "\n" +
                    "Item : " + item + "\n" +
                    "Price: " + price + "\n" +
                    "Value: " + value + "\n")

                 .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int id) {

           }
       })
       .show();

I would like to achieve this :

enter image description here

Upvotes: 0

Views: 1268

Answers (1)

njzk2
njzk2

Reputation: 39406

Option A (dirty) : get the alert text view and set a fixed size font

Option B (clean) : use a custom view and a tablelayout (see http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout )

Upvotes: 1

Related Questions