【发布时间】:2017-03-16 14:19:53
【问题描述】:
我正在执行一项任务,该任务要求我在 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);
}
我尝试过使用 String.format() 但这似乎也不适合我,我想知道有没有人有办法让所有列在 android 中完美排列?
【问题讨论】:
-
使用等宽(真的会起作用)......但更严重的是......表格(带列)在Android上太糟糕了(记住你必须支持多种设备的尺寸)......使用一些带有漂亮卡片的 ListView 或 RecyclerView
-
@Selvin 如何将我的文本设置为等宽字体?我是在 android studio 的 TextView 框中执行此操作还是对实际文件执行此操作?
-
通过设置TextView的字体
-
@Selvin 我爱你!非常感谢:)
-
请告诉我,您只是想检查一下或展示一些原型,您不会在生产中使用它......这是一个糟糕的主意......请查看 cw 的答案以获得更好的解决方案