在Android Studio中以完美的列打印 我正处于一个任务的中间,要求我在Eclipse和Android Studio中打印出一张足球联赛表。当我在eclipse中使用以下代码时,它完美地排列了所有内容,但在android中使用时会产生以下结果: public void printResults(InputStream here){ Main letsRun = new Main(here); results = letsRun.runCode(); String presentation = ""; StringBuilder bld = new StringBuilder(); String results2 = ""; presentation = "TEAM NAME Wins Draws Losses Points" + "\n"; for(Standings test : results){ String test2 = test.getTeam() +" " + test.getWins() +" " + test.getDraws()+" " + test.getLosses() +" "+test.getPoints() +"\n"; bld.append(test2); } results2 = bld.toString(); presentation += "The percentage of games predicted successfully for this season was: " + letsRun.getSuccessfullyPredicted(); Intent intent = new Intent(getBaseContext(), DisplayResults.class); intent.putExtra("KEY", presentation); intent.putExtra("results", results2); startActivity(intent); }
在Android Studio中以完美的列打印 我正处于一个任务的中间,要求我在Eclipse和Android Studio中打印出一张足球联赛表。当我在eclipse中使用以下代码时,它完美地排列了所有内容,但在android中使用时会产生以下结果: public void printResults(InputStream here){ Main letsRun = new Main(here); results = letsRun.runCode(); String presentation = ""; StringBuilder bld = new StringBuilder(); String results2 = ""; presentation = "TEAM NAME Wins Draws Losses Points" + "\n"; for(Standings test : results){ String test2 = test.getTeam() +" " + test.getWins() +" " + test.getDraws()+" " + test.getLosses() +" "+test.getPoints() +"\n"; bld.append(test2); } results2 = bld.toString(); presentation += "The percentage of games predicted successfully for this season was: " + letsRun.getSuccessfullyPredicted(); Intent intent = new Intent(getBaseContext(), DisplayResults.class); intent.putExtra("KEY", presentation); intent.putExtra("results", results2); startActivity(intent); },android,printing,Android,Printing,我尝试过使用String.format(),但这似乎对我也不起作用,我想知道有没有人能在android中让所有列完美地排列起来?ASCII艺术(包括像您这样的表格)需要单空格字体 因此,一种方法是坚持使用现有代码,但在显示输出时使用单空格字体 更好的办法包括: 使用表格布局创建实际表格 使用HTML和适当的标记(例如,,,)来创建实际的表 使用monospace(说真的,它会起作用)。。。但更严重的是。。。Android上的表(带列)非常糟糕(请记住,您必须支持多种设备大小)。。。使用一些Li
我尝试过使用String.format(),但这似乎对我也不起作用,我想知道有没有人能在android中让所有列完美地排列起来?ASCII艺术(包括像您这样的表格)需要单空格字体 因此,一种方法是坚持使用现有代码,但在显示输出时使用单空格字体 更好的办法包括:
- 使用
创建实际表格表格布局
- 使用HTML和适当的标记(例如,
,
,
)来创建实际的表