ViewLogTable.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package de.tudarmstadt.informatik.hostage.ui;
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.widget.ScrollView;
  5. import android.widget.TextView;
  6. import de.tudarmstadt.informatik.hostage.logging.Record;
  7. import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
  8. /**
  9. * Creates a simple log view. Shows the Information for every attack. The format
  10. * ist defined in {@link Record#toString(int)}.
  11. *
  12. * @author Lars Pandikow
  13. *
  14. */
  15. public class ViewLogTable extends Activity {
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. UglyDbHelper dbh = new UglyDbHelper(getBaseContext());
  20. StringBuffer log = new StringBuffer();
  21. // Create a log entry for every attack in the Database
  22. for (Record record : dbh.getAllRecords()) {
  23. log.append(record.toString());
  24. }
  25. ScrollView scroll = new ScrollView(this);
  26. TextView text = new TextView(getApplicationContext());
  27. text.setText(log);
  28. text.setTextAppearance(this, android.R.style.TextAppearance_Medium);
  29. scroll.addView(text);
  30. setContentView(scroll);
  31. }
  32. }