我很想开发fororid,我想知道在按下按钮后如何将2D arraylist的内容打印到屏幕上。也没有寻找任何过于复杂的事情。一旦我可以打印数据,那将是辉煌的。我有我的方法,应该打印,高级联赛的固定装置。只是想知道如何打印这些灯具。获取灯具的代码本身很好,它只是我不知道如何打印出来。干杯啦!
// View Remaining Fixtures
public void ViewFixtures(ArrayList<ArrayList<String>> teamsOrPlayers, ArrayList<ArrayList<String>> fixtures, Integer fixturesPlayedToDate) {
TextView display = (TextView)findViewById(R.id.ViewRemainingFixturesButton);
String message = "League is complete";
if(fixturesPlayedToDate != fixtures.get(0).size()) {
for(int i = fixturesPlayedToDate; i < fixtures.get(0).size(); i++) {
int homeTeam = Integer.parseInt(fixtures.get(1).get(i));
int awayTeam = Integer.parseInt(fixtures.get(2).get(i));
String homeTeamStr = teamsOrPlayers.get(1).get(homeTeam - 1);
String awayTeamStr = teamsOrPlayers.get(1).get(awayTeam - 1);
display.setTex;
display.setText(awayTeamStr);
}
} else {
display.setText(message);
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_remaining_fixtures);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
答案 0 :(得分:1)
如果您只想记录LogCat:
private void logInfo() {
for (ArrayList<String> arrayList : outerArrayList) {
for (String s: arrayList) {
Log.d("tag", s);
}
}
}
如果你想在屏幕上看到它:
private void displayInfo() {
StringBuilder stringBuilder = new StringBuilder();
for (ArrayList<String> arrayList: outerArrayList) {
for (String s: arrayList) {
sb.append(s);
sb.append('\n');
}
}
String yourInfo = stringBuilder.toString();
yourTextView.setText(yourInfo); // assumes your textEdit is multiline
}