1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.example.ueberwachungssystem.Fragments;
-
- import android.content.Context;
- import android.content.Intent;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- import android.widget.TextView;
-
- import androidx.fragment.app.Fragment;
-
- import com.example.ueberwachungssystem.MeinAdapter;
- import com.example.ueberwachungssystem.R;
-
- import java.io.File;
- import java.util.Arrays;
- import java.util.List;
-
- public class Fragment2 extends Fragment {
- private String text;
- private Context c;
- private final static String KEY_TEXT = "KEY_TEXT" ;
- private void log(String nachricht) {
- Log.d(this.getClass().getSimpleName(), nachricht);
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- log( "onCreateView" );
- View view = inflater.inflate(R.layout.fragment2, container, false );
- // TextView Sensor = (TextView) view.findViewById(R.id.Aufzeichnungen);
- // Sensor.setText(text);
- return view;
- }
- public static Fragment2 erstellen(String text) {
- Fragment2 fragment = new Fragment2();
- Bundle b = new Bundle();
- b.putString(KEY_TEXT, text);
- fragment.setArguments(b);
- return fragment;
- }
- @Override
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- Bundle args = getArguments();
- c = getContext();
- ListView listView = new ListView(c);
- listView.setAdapter(new MeinAdapter(c, getVideoFiles()));
- if (args != null) {
- text = args.getString(KEY_TEXT);
- log("onCreate: text=" + text);
- } else {
- log("onCreate");
- }
- }
- public List<File> getVideoFiles(){
- File directory = c.getFilesDir();
- File[] files = directory.listFiles();
- assert files != null;
- return Arrays.asList(files);
- }
- }
|