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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. setContentView(R.layout.fragment2);
  47. listView.setAdapter(new MeinAdapter(c, getVideoFiles()));
  48. if (args != null) {
  49. text = args.getString(KEY_TEXT);
  50. log("onCreate: text=" + text);
  51. } else {
  52. log("onCreate");
  53. }
  54. }
  55. public List<File> getVideoFiles(){
  56. File directory = c.getFilesDir();
  57. File[] files = directory.listFiles();
  58. assert files != null;
  59. return Arrays.asList(files);
  60. }
  61. }