Good afternoon everyone, I have succesfully created a working alertdialog, which is shown in following link: https://i.stack.imgur.com/XR1Pm.png
Later I thought that it would be better if I moved the information of computer in right of information of first player (shown here: https://i.stack.imgur.com/rj3M6.png ). It would increase readability of message and generally look better.
I have searched over the internet the way of doing it, but I couldn't find the solution. Could anyone tell me how I could efficiently reach this effect shown in picture 2? Thanks in advice.
Here is my code of dialogalert (it won't be compiled but it mostly uses data from SharedPreferences, strings from strings.xml and it should be understood):
private void showMatchResults(int[] p1results, int[] p2results) {
AlertDialog.Builder aldb = new AlertDialog.Builder(this);
aldb.setTitle(getString(R.string.match_summary));
aldb
.setMessage(matchResults_message(p1results, p2results))
.setCancelable(false)
.setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = aldb.create();
alertDialog.show();
}
private String matchResults_message(int[] p1results, int[] p2results) {
StringBuilder sb = new StringBuilder();
sb.append(data.getString("player1", getApplicationContext().getString(R.string.player1)));
int[] results = new int[6];
System.arraycopy(p1results, 0, results, 0, p1results.length);
System.arraycopy(p2results, 0, results, p1results.length, p2results.length);
sb.append(System.getProperty("line.separator"));
for (int i = 0; i < results.length; i++) {
if (i == 3) {
sb.append(System.getProperty("line.separator"));
if (mode.equals("Two"))
sb.append(data.getString("player2", getApplicationContext().getString(R.string.player2)));
else sb.append(getString(R.string.computer) + " " + ComputerAI.getDifficulty(this));
sb.append(System.getProperty("line.separator"));
}
if (i == 0 || i == 3) sb.append(getString(R.string.wins));
else if (i == 1 || i == 4) sb.append(getString(R.string.draws));
else sb.append(getString(R.string.loses));
sb.append(" "+results[i]);
sb.append(System.getProperty("line.separator"));
}
return sb.toString();
}