Gruppe 1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Fragment2.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.example.ueberwachungssystem.Fragments;
  2. import android.content.Context;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.util.Log;
  6. import android.view.LayoutInflater;
  7. import android.view.View;
  8. import android.view.ViewGroup;
  9. import android.widget.ArrayAdapter;
  10. import android.widget.ListView;
  11. import android.widget.TextView;
  12. import androidx.fragment.app.Fragment;
  13. import com.example.ueberwachungssystem.MeinAdapter;
  14. import com.example.ueberwachungssystem.R;
  15. import java.io.File;
  16. import java.util.Arrays;
  17. import java.util.List;
  18. public class Fragment2 extends Fragment {
  19. private String text;
  20. private Context c;
  21. private final static String KEY_TEXT = "KEY_TEXT" ;
  22. private void log(String nachricht) {
  23. Log.d(this.getClass().getSimpleName(), nachricht);
  24. }
  25. @Override
  26. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
  27. log( "onCreateView" );
  28. View view = inflater.inflate(R.layout.fragment2, container, false );
  29. // TextView Sensor = (TextView) view.findViewById(R.id.Aufzeichnungen);
  30. // Sensor.setText(text);
  31. return view;
  32. }
  33. public static Fragment2 erstellen(String text) {
  34. Fragment2 fragment = new Fragment2();
  35. Bundle b = new Bundle();
  36. b.putString(KEY_TEXT, text);
  37. fragment.setArguments(b);
  38. return fragment;
  39. }
  40. @Override
  41. public void onCreate(Bundle bundle) {
  42. super.onCreate(bundle);
  43. Bundle args = getArguments();
  44. c = getContext();
  45. ListView listView = new ListView(c);
  46. listView.setAdapter(new MeinAdapter(c, getVideoFiles()));
  47. if (args != null) {
  48. text = args.getString(KEY_TEXT);
  49. log("onCreate: text=" + text);
  50. } else {
  51. log("onCreate");
  52. }
  53. }
  54. public List<File> getVideoFiles(){
  55. File directory = c.getFilesDir();
  56. File[] files = directory.listFiles();
  57. assert files != null;
  58. return Arrays.asList(files);
  59. }
  60. }