Browse Source

add interface

房丽婷 3 years ago
parent
commit
9a8952e193

+ 2 - 1
.idea/misc.xml

@@ -3,7 +3,8 @@
   <component name="DesignSurface">
     <option name="filePathToZoomLevelMap">
       <map>
-        <entry key="..\:/Users/32083/AndroidStudioProjects/MyMusic/app/src/main/res/layout/activity_main.xml" value="0.1" />
+        <entry key="..\:/Users/32083/AndroidStudioProjects/MyMusic/app/src/main/res/layout/activity_main.xml" value="0.16" />
+        <entry key="..\:/Users/32083/AndroidStudioProjects/MyMusic/app/src/main/res/layout/cell.xml" value="0.1" />
       </map>
     </option>
   </component>

+ 5 - 0
app/src/main/java/com/example/mymusic/CellPrototypeInterface.java

@@ -0,0 +1,5 @@
+package com.example.mymusic;
+
+public interface CellPrototypeInterface {
+    void cellClicked(Music music);
+}

+ 18 - 0
app/src/main/java/com/example/mymusic/Music.java

@@ -0,0 +1,18 @@
+package com.example.mymusic;
+
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+public class Music extends RecyclerView.ViewHolder {
+    TextView textView;
+    CellPrototypeInterface cellPrototypeInterface;
+
+    public Music(@NonNull View itemView) {
+        super(itemView);
+        textView = itemView.findViewById(R.id.);
+
+    }
+}

+ 6 - 10
app/src/main/java/com/example/mymusic/MusicAdapter.java

@@ -5,16 +5,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Adapter;
 
-public class MusicAdapter extends Adapter {
-    @Override
-    public void registerDataSetObserver(DataSetObserver dataSetObserver) {
-
-    }
-
-    @Override
-    public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
-
-    }
+public class MusicAdapter extends Adapter<Music.> implements CellPrototypeInterface{
 
     @Override
     public int getCount() {
@@ -55,4 +46,9 @@ public class MusicAdapter extends Adapter {
     public boolean isEmpty() {
         return false;
     }
+
+    @Override
+    public void cellClicked(Music music) {
+
+    }
 }

+ 6 - 0
app/src/main/res/layout/cell.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+</androidx.constraintlayout.widget.ConstraintLayout>