RecyclerView.Adapter
This commit is contained in:
parent
8151d0d807
commit
adf88f8162
|
@ -47,4 +47,6 @@ dependencies {
|
|||
implementation ("io.github.scwang90:refresh-header-two-level:2.1.0") //二级刷新头
|
||||
implementation ("io.github.scwang90:refresh-footer-ball:2.1.0") //球脉冲加载
|
||||
implementation ("io.github.scwang90:refresh-footer-classics:2.1.0")
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package com.hnucm.c202201020141;
|
||||
|
||||
public class Chat {
|
||||
public String name;
|
||||
public String content;
|
||||
public String time;
|
||||
public String doctor;
|
||||
public String num;
|
||||
|
||||
public String imgurl;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package com.hnucm.c202201020141;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -13,6 +8,12 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter;
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader;
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
|
||||
|
@ -32,12 +33,11 @@ public class HomeActivity2 extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
setContentView(R.layout.activity_home2);
|
||||
for(int i=0;i<20;i++){
|
||||
Chat chat=new Chat();
|
||||
chat.name="姓名"+i;
|
||||
chat.content="聊天内容"+i;
|
||||
chat.time="聊天时间"+i;
|
||||
chat.doctor="姓名"+i;
|
||||
chat.num="聊天内容"+i;
|
||||
chatList.add(chat);
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,8 @@ public class HomeActivity2 extends AppCompatActivity {
|
|||
//构造一些数据 ->todo 网络请求得到
|
||||
for(int i=0;i<20;i++){
|
||||
Chat chat=new Chat();
|
||||
chat.name="姓名"+i;
|
||||
chat.content="聊天内容"+i;
|
||||
chat.time="聊天时间"+i;
|
||||
chat.doctor="姓名"+i;
|
||||
chat.num="聊天内容"+i;
|
||||
chatList.add(chat);
|
||||
}
|
||||
smartRefreshLayout.finishRefresh(2000);
|
||||
|
@ -72,9 +71,9 @@ public class HomeActivity2 extends AppCompatActivity {
|
|||
//上拉加载
|
||||
for(int i=0;i<20;i++){
|
||||
Chat chat=new Chat();
|
||||
chat.name="姓名"+i;
|
||||
chat.content="聊天内容"+i;
|
||||
chat.time="聊天时间"+i;
|
||||
chat.doctor="姓名"+i;
|
||||
chat.num="聊天内容"+i;
|
||||
|
||||
chatList.add(chat);
|
||||
}
|
||||
smartRefreshLayout.finishLoadMore(2000);
|
||||
|
@ -111,17 +110,16 @@ public class HomeActivity2 extends AppCompatActivity {
|
|||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||
Chat chat=chatList.get(position);
|
||||
holder.textView.setText(chatList.get(position).name);
|
||||
holder.textView2.setText(chatList.get(position).content);
|
||||
holder.textView3.setText(chatList.get(position).time);
|
||||
holder.Layout.setOnClickListener(new View.OnClickListener() {
|
||||
holder.textView.setText(chatList.get(position).doctor);
|
||||
holder.textView2.setText(chatList.get(position).num);
|
||||
/*holder.Layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent=new Intent(HomeActivity2.this, ChatActivity.class);
|
||||
Intent intent=new Intent(MainActivity.this, ChatActivity.class);
|
||||
intent.putExtra("name",chat.name);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
}
|
||||
//显示item的条数
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -4,73 +4,53 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".HomeActivity2">
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="409dp"
|
||||
android:layout_height="580dp"
|
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/smartlayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="600dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView24">
|
||||
|
||||
|
||||
|
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/smartlayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView24"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="76dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/_2024_06_14_191105" />
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView25"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/_2024_06_14_191544" />
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView28"
|
||||
android:id="@+id/textView24"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginTop="56dp"
|
||||
android:text="专家分类"
|
||||
android:textSize="16sp"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/smartlayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView21"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="64dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/_2024_06_14_191544" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,13 +36,14 @@
|
|||
app:layout_constraintStart_toEndOf="@+id/imageView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:text="TextView"
|
||||
<ImageView
|
||||
android:id="@+id/imageView23"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="44dp"
|
||||
android:layout_marginEnd="28dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/_2024_06_16_011738" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue