5 changed files with 81 additions and 11 deletions
@ -1,25 +1,45 @@ |
|||||||
package cc.niushuai.didicheck.ui.main.home; |
package cc.niushuai.didicheck.ui.main.home; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.view.View; |
||||||
import android.view.ViewGroup; |
import android.view.ViewGroup; |
||||||
|
|
||||||
import androidx.annotation.NonNull; |
import androidx.annotation.NonNull; |
||||||
import androidx.recyclerview.widget.RecyclerView; |
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import cc.niushuai.didicheck.R; |
||||||
|
import cc.niushuai.didicheck.biz.entity.CheckRecord; |
||||||
|
import cn.hutool.core.date.DateUtil; |
||||||
|
|
||||||
public class HomeRecycleViewAdapter extends RecyclerView.Adapter<HomeRecycleViewHolder> { |
public class HomeRecycleViewAdapter extends RecyclerView.Adapter<HomeRecycleViewHolder> { |
||||||
|
|
||||||
|
private final List<CheckRecord> checkRecordList = new ArrayList<>(); |
||||||
|
private final Context context; |
||||||
|
|
||||||
|
public HomeRecycleViewAdapter(Context context, List<CheckRecord> checkRecordList) { |
||||||
|
this.context = context; |
||||||
|
this.checkRecordList.addAll(checkRecordList); |
||||||
|
} |
||||||
|
|
||||||
@NonNull |
@NonNull |
||||||
@Override |
@Override |
||||||
public HomeRecycleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
public HomeRecycleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
||||||
return null; |
View view = View.inflate(context, R.layout.item_list, null); |
||||||
|
return new HomeRecycleViewHolder(view); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void onBindViewHolder(@NonNull HomeRecycleViewHolder holder, int position) { |
public void onBindViewHolder(@NonNull HomeRecycleViewHolder holder, int position) { |
||||||
|
CheckRecord checkRecord = checkRecordList.get(position); |
||||||
|
holder.titleTextView.setText(checkRecord.getName()); |
||||||
|
holder.contentTextView.setText(DateUtil.formatDate(checkRecord.getCreateDate())); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public int getItemCount() { |
public int getItemCount() { |
||||||
return 0; |
return checkRecordList.size(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,13 +1,21 @@ |
|||||||
package cc.niushuai.didicheck.ui.main.home; |
package cc.niushuai.didicheck.ui.main.home; |
||||||
|
|
||||||
import android.view.View; |
import android.view.View; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
import androidx.annotation.NonNull; |
import androidx.annotation.NonNull; |
||||||
import androidx.recyclerview.widget.RecyclerView; |
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import cc.niushuai.didicheck.R; |
||||||
|
|
||||||
public class HomeRecycleViewHolder extends RecyclerView.ViewHolder { |
public class HomeRecycleViewHolder extends RecyclerView.ViewHolder { |
||||||
|
|
||||||
|
protected TextView titleTextView; |
||||||
|
protected TextView contentTextView; |
||||||
|
|
||||||
public HomeRecycleViewHolder(@NonNull View itemView) { |
public HomeRecycleViewHolder(@NonNull View itemView) { |
||||||
super(itemView); |
super(itemView); |
||||||
|
titleTextView = itemView.findViewById(R.id.item_list_title_textView); |
||||||
|
contentTextView = itemView.findViewById(R.id.item_list_content_textView); |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,8 +1,29 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent"> |
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/item_list_title_textView" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginStart="29dp" |
||||||
|
android:layout_marginTop="33dp" |
||||||
|
android:text="标题" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/item_list_content_textView" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginStart="4dp" |
||||||
|
android:layout_marginTop="18dp" |
||||||
|
android:text="内容" |
||||||
|
app:layout_constraintStart_toStartOf="@id/item_list_title_textView" |
||||||
|
app:layout_constraintTop_toBottomOf="@id/item_list_title_textView" /> |
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout> |
</androidx.constraintlayout.widget.ConstraintLayout> |
Loading…
Reference in new issue