ViewLogTable.java 1.1 KB

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