package com.example.ueberwachungssystem.Fragments; | |||||
import android.content.Context; | |||||
import android.os.Bundle; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.AdapterView; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ListView; | |||||
import android.widget.Toast; | |||||
import androidx.fragment.app.Fragment; | |||||
import com.example.ueberwachungssystem.R; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
public class VideoFileFragment extends Fragment { | |||||
private ListView listView; | |||||
private ArrayAdapter<String> adapter; | |||||
@Override | |||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |||||
View rootView = inflater.inflate(R.layout.video_file_fragment, container, false); | |||||
listView = rootView.findViewById(R.id.listView); | |||||
adapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, getData()); | |||||
listView.setAdapter(adapter); | |||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |||||
@Override | |||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |||||
// Handle item click event here | |||||
String selectedItem = adapter.getItem(position); | |||||
Toast.makeText(requireContext(), selectedItem, Toast.LENGTH_SHORT).show(); | |||||
} | |||||
}); | |||||
return rootView; | |||||
} | |||||
private List<String> getData() { | |||||
// Add your data source here, e.g., an array or a list | |||||
List<String> data = new ArrayList<>(); | |||||
data.add("Item 1"); | |||||
data.add("Item 2"); | |||||
data.add("Item 3"); | |||||
return data; | |||||
} | |||||
} |
import androidx.camera.core.ExperimentalGetImage; | import androidx.camera.core.ExperimentalGetImage; | ||||
import androidx.fragment.app.Fragment; | import androidx.fragment.app.Fragment; | ||||
import androidx.fragment.app.FragmentManager; | |||||
import androidx.fragment.app.FragmentTransaction; | import androidx.fragment.app.FragmentTransaction; | ||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.appcompat.app.AppCompatActivity; | import androidx.appcompat.app.AppCompatActivity; | ||||
import android.view.Menu; | import android.view.Menu; | ||||
import android.view.MenuItem; | import android.view.MenuItem; | ||||
import android.view.View; | import android.view.View; | ||||
import android.widget.AdapterView; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | import android.widget.Button; | ||||
import android.widget.ListView; | |||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import android.widget.ToggleButton; | import android.widget.ToggleButton; | ||||
import com.example.ueberwachungssystem.Fragments.Fragment2; | import com.example.ueberwachungssystem.Fragments.Fragment2; | ||||
import com.example.ueberwachungssystem.Detection.DetectorService; | import com.example.ueberwachungssystem.Detection.DetectorService; | ||||
import com.example.ueberwachungssystem.Fragments.Fragment3; | import com.example.ueberwachungssystem.Fragments.Fragment3; | ||||
import com.example.ueberwachungssystem.Fragments.VideoFileFragment; | |||||
import java.util.ArrayList; | |||||
@ExperimentalGetImage | @ExperimentalGetImage | ||||
public class MainActivity extends AppCompatActivity { | public class MainActivity extends AppCompatActivity { | ||||
private Fragment1 fragment1; | private Fragment1 fragment1; | ||||
private Fragment2 fragment2; | private Fragment2 fragment2; | ||||
private Fragment3 fragment3; | private Fragment3 fragment3; | ||||
private VideoFileFragment videoFileFragment = new VideoFileFragment(); | |||||
private DetectorService detectorService = new DetectorService(); | private DetectorService detectorService = new DetectorService(); | ||||
int num=0; | |||||
int num = 0; | |||||
//Textviews | //Textviews | ||||
private TextView Auswahl; | private TextView Auswahl; | ||||
private TextView AoderA; | private TextView AoderA; | ||||
public void onClickZeigeFragment2(View view) { | public void onClickZeigeFragment2(View view) { | ||||
Button button = (Button) view; | Button button = (Button) view; | ||||
zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos")); | |||||
//zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos")); | |||||
zeigeFragment(videoFileFragment); | |||||
} | } | ||||
public void onClickZeigeFragment3(View view) { | public void onClickZeigeFragment3(View view) { | ||||
Button button = (Button) view; | Button button = (Button) view; |
package com.example.ueberwachungssystem; | |||||
import android.content.Context; | |||||
import android.os.Bundle; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.TextView; | |||||
import androidx.annotation.NonNull; | |||||
import java.util.List; | |||||
public class VideoAdapter extends ArrayAdapter<String> { | |||||
private List<String> fileList; | |||||
private OnFileClickListener listener; | |||||
public VideoAdapter (Context context, List<String> fileList, OnFileClickListener listener) { | |||||
super(context, 0, fileList); | |||||
this.fileList = fileList; | |||||
this.listener = listener; | |||||
} | |||||
@Override | |||||
public View getView(final int position, View convertView, ViewGroup parent) { | |||||
if (convertView == null) { | |||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_file, parent, false); | |||||
} | |||||
TextView fileNameText = convertView.findViewById(R.id.file_name_text); | |||||
final String fileName = fileList.get(position); | |||||
fileNameText.setText(fileName); | |||||
convertView.setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
listener.onFileClick(fileName); | |||||
listener.onFileClick(fileName); | |||||
} | |||||
}); | |||||
return convertView; | |||||
} | |||||
public interface OnFileClickListener { | |||||
View onCreateView(LayoutInflater inflater, ViewGroup container, | |||||
Bundle savedInstanceState); | |||||
void onFileClick(String fileName); | |||||
} | |||||
} |
</LinearLayout> | </LinearLayout> | ||||
</ScrollView> | </ScrollView> | ||||
--> | --> | ||||
<ListView | |||||
android:id = "@+id/listView" | |||||
android:layout_width = "wrap_content" | |||||
android:layout_height = "wrap_content"/> | |||||
</RelativeLayout> | </RelativeLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
xmlns:tools="http://schemas.android.com/tools" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent"> | |||||
<!-- list_item_file.xml --> | |||||
<TextView | |||||
xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:id="@+id/file_name_text" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:textSize="16sp" | |||||
android:padding="8dp" | |||||
tools:ignore="MissingConstraints" /> | |||||
</androidx.constraintlayout.widget.ConstraintLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
xmlns:tools="http://schemas.android.com/tools" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:gravity="center_horizontal" | |||||
android:orientation="vertical" | |||||
android:background="@android:color/holo_blue_light"> | |||||
<ListView | |||||
android:id = "@+id/listView" | |||||
android:layout_width = "wrap_content" | |||||
android:layout_height = "wrap_content" | |||||
tools:ignore="MissingConstraints" /> | |||||
</androidx.constraintlayout.widget.ConstraintLayout> |