I have an alert dialog that works fine, but I suspect I can clean up my code some. I'm using a stringBuilder
to help pull together the message, in addition to using String.format to get the spacing pleasant for each line. It's the String.format
that keeps me from appending like normal. I'd rather not use four (4) String Objects to accomplish all this. Show me a more concise coding and be cool forever.
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setCancelable(true);
builder.setTitle("Total Counts");
StringBuilder stringBuilder = new StringBuilder();
String one= String.format("%-10s %s", calCount1, "#1 count\n");
String two= String.format("%-10s %s", calCount2, "#2 count\n");
String three= String.format("%-10s %s", calCount3, "#3 count\n");
String four= String.format("%-10s %s", calCount4, "#4 count\n");
stringBuilder.append(one);
stringBuilder.append(two);
stringBuilder.append(three);
stringBuilder.append(four);
builder.setMessage(stringBuilder.toString());
...