ViewLogTable.java 1.2 KB

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