Browse Source

changed layout a bit, looks pretty nice with betreff etc

Simon Hammer 4 năm trước cách đây
mục cha
commit
08e80c4d96

+ 18 - 8
app/src/main/java/com/noahvogt/miniprojekt/ui/home/CustomAdapter.java

@@ -26,15 +26,19 @@ public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder
      * (custom ViewHolder).
      */
     public class ViewHolder extends RecyclerView.ViewHolder {
-        private TextView textView;
-        private TextView Betreff;
+        private TextView name;
+        private TextView betreff;
+        private TextView date;
+        private TextView begin;
 
         public ViewHolder(View view) {
             super(view);
             // Define click listener for the ViewHolder's View
 
-            textView = (TextView) view.findViewById(R.id.textView);
-            Betreff = (TextView) view.findViewById(R.id.Betreff);
+            name = (TextView) view.findViewById(R.id.textView);
+            betreff = (TextView) view.findViewById(R.id.betreff);
+            date = (TextView) view.findViewById(R.id.date);
+            begin = (TextView) view.findViewById(R.id.begin);
         }
 
         //public TextView getTextView() {
@@ -81,10 +85,16 @@ public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder
         Data contact = localDataSet.get(position);
 
         // Set item views based on your views and data model
-        TextView textView = viewHolder.textView;
-        textView.setText(contact.getName());
-        TextView betreffView = viewHolder.Betreff;
-        betreffView.setText(contact.getDate());
+        TextView nameView = viewHolder.name;
+        TextView betreffView = viewHolder.betreff;
+        TextView dateView = viewHolder.date;
+        TextView beginView = viewHolder.begin;
+
+        nameView.setText(contact.getName());
+        betreffView.setText(contact.getBetreff());
+        dateView.setText(contact.getDate());
+        beginView.setText(contact.getBegin());
+
 
     }
 

+ 10 - 2
app/src/main/java/com/noahvogt/miniprojekt/ui/home/Data.java

@@ -5,11 +5,16 @@ import java.util.ArrayList;
 public class Data {
     private String mName;
     private String mdate;
+    private String mBetreff;
+    private String mBegin;
 
 
-    public Data(String name, String date) {
+    public Data(String name, String date, String begin, String betreff) {
         mName = name;
         mdate = date;
+        mBegin = begin;
+        mBetreff = betreff;
+
 
     }
 
@@ -17,6 +22,8 @@ public class Data {
         return mName;
     }
     public String getDate(){return mdate;}
+    public String getBetreff(){return mBetreff;}
+    public String getBegin(){return mBegin;}
 
 
 
@@ -26,7 +33,8 @@ public class Data {
         ArrayList<Data> contacts = new ArrayList<Data>();
 
         for (int i = 1; i <= numContacts; i++) {
-            contacts.add(new Data("Person " + ++lastContactId, "14.04.2021"));
+            contacts.add(new Data("Person " + ++lastContactId, "14.04.2021", "This email begins with..",
+                    "My Betreff is no that god"));
         }
 
         return contacts;

+ 10 - 9
app/src/main/res/layout/fragment_home.xml

@@ -16,19 +16,20 @@
         android:layout_width="wrap_content"
         android:textSize="25dp"/>
 
-    <!--Button
-        android:id="@+id/message_button"
+    <TextView
+        android:id="@+id/begin"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:paddingLeft="16dp"
-        android:paddingRight="16dp"
-        android:textSize="10sp"
-        /-->
+        android:layout_height="match_parent"
+        android:layout_row="2"
+        android:layout_column="0"
+        android:textSize="20sp"
+        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
+
 
     <TextView
-        android:id="@+id/Betreff"
+        android:id="@+id/betreff"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:layout_height="match_parent"
         android:layout_row="1"
         android:layout_column="0"
         android:textSize="20sp"

+ 0 - 24
app/src/main/res/layout/recycler_view_frag.xml

@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:id="@+id/sample_main_layout">
-
-    <FrameLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <!--android:layout_marginLeft="@dimen/margin_medium"
-        android:layout_marginRight="@dimen/margin_medium"
-        android:gravity="center_vertical"-->
-
-        <androidx.recyclerview.widget.RecyclerView
-            android:id="@+id/idk"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" />
-        <!--android:text="@string/element_text"-->
-    </FrameLayout><!--RelativeLayout from https://www.c-sharpcorner.com/article/recyclerview-in-andriod-with-java/
-                        and FrameLayout was befor from https://developer.android.com/guide/topics/ui/layout/recyclerview#java-->
-</androidx.constraintlayout.widget.ConstraintLayout>