Change text color in Alertdialog

Asked

Viewed 574 times

3

I’m creating an Android app and would like to know how I change the color to red of the phrase "SPI equation" in this Alertdialog ?

AlertDialog.Builder dlg = new AlertDialog.Builder(this);
    dlg.setMessage("Equação SPI \n\n"+
        "Calculos:\n\n" +
        "L1 vezes "+D1+" menos a L2.\n " +
        "L1 vezes "+D2+" menos a L3\n\n"+
        "Temos:\n\n"+
        valorA1+"X+"+valorB1+"Y+"+valorC1+"Z="+valorK1+"\n"+
        L2A+"X+"+L2B+"Y+"+L2C+"Z="+L2K+"\n"+
        D3A+"X+"+D3B+"Z+"+D3C+"Z="+D3K+"\n\n"+
        "Por fim L2 vezes "+D3+" menos a L3\n\n"+
        "Equações Escalonadas:\n\n"+
        valorA1+"X+"+valorB1+"Y+"+valorC1+"Z="+valorK1+"\n"+
        L2A+"X+"+L2B+"Y+"+L2C+"Z="+L2K+"\n"+
        L3A+"X+"+L3B+"Z+"+L3C+"Z="+L3K+"\n\n");

dlg.setNeutralButton("ok", null);
dlg.show();

1 answer

4


Do not use setMessage use setView and do all the training by XML.

AlertDialog.Builder dlg = new AlertDialog.Builder(this);
dlg.setView(R.layout.um_layout_qualquer ou [view inflada dinamicamente]);

dlg.setNeutralButton("ok", null);
dlg.show();

Browser other questions tagged

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