Java tutorial
//package com.java2s; //License from project: Apache License import android.util.Log; import java.util.ArrayList; public class Main { public static String getCommandList(ArrayList<String> commands) { if (commands == null || commands.size() == 0) { return ""; } StringBuilder sb = new StringBuilder(); for (String commandPattern : commands) { String[] cmdSplit = commandPattern.split("~"); if (cmdSplit.length != 3) { Log.e("DebugGhost", "Cannot read command pattern '" + commandPattern + "', skipping ..."); continue; } if (cmdSplit[2].contains("[") == true && cmdSplit[2].contains("]") == true) { continue; } sb.append( "<button type=\"button\" style=\"margin-bottom: 5px;\" class=\"btn btn-default\" onclick=\"postCommand('/commands/"); sb.append(cmdSplit[1]); sb.append("','"); sb.append(cmdSplit[2]); sb.append("');\">"); sb.append(cmdSplit[0]); sb.append("</button>"); } return sb.toString(); } }