fragment_index

master
hjw 4 years ago
parent cdf4b27c88
commit ff7af13a9e

@ -0,0 +1,62 @@
package com.example.leudaemialikeme.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Recnews;
import java.util.List;
public class RecnewsAdapter extends RecyclerView.Adapter<RecnewsAdapter.ViewHolder> {
private List<Recnews> mRecnewsList;
static class ViewHolder extends RecyclerView.ViewHolder{
ImageView image;
TextView theme;
TextView intro;
TextView visNum;
TextView time;
public ViewHolder(View view){
super(view);
image=(ImageView)view.findViewById(R.id.recNews_image);
theme=(TextView)view.findViewById(R.id.recNews_theme);
intro=(TextView)view.findViewById(R.id.recNews_intro);
visNum=(TextView)view.findViewById(R.id.recNews_visNum);
time=(TextView)view.findViewById(R.id.recNews_time);
}
}
public RecnewsAdapter(List<Recnews> recnewsList){
mRecnewsList=recnewsList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.recnews_item,parent,false);
ViewHolder holder=new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecnewsAdapter.ViewHolder holder, int position) {
Recnews recnews=mRecnewsList.get(position);
holder.image.setImageResource(recnews.getImageNum());
holder.visNum.setText(String.valueOf(recnews.getVisNum()));
holder.intro.setText(recnews.getIntro());
holder.theme.setText(recnews.getTheme());
holder.time.setText(recnews.getTime());
}
@Override
public int getItemCount() {
return mRecnewsList.size();
}
}

@ -0,0 +1,52 @@
package com.example.leudaemialikeme;
import java.io.Serializable;
public class Recnews implements Serializable {
private static final long serialVersionUID = 1L;
private int imageNum;
private String theme;
private String intro;
private int visNum;
private String time;
public int getImageNum(){
return imageNum;
}
public void setImageNum(int imageNum){
this.imageNum=imageNum;
}
public String getTheme(){
return theme;
}
public void setTheme(String theme){
this.theme=theme;
}
public String getIntro(){
return intro;
}
public void setIntro(String intro){
this.intro=intro;
}
public int getVisNum(){
return visNum;
}
public void setVisNum(int visNum) {
this.visNum = visNum;
}
public String getTime(){
return time;
}
public void setTime(String time) {
this.time = time;
}
public Recnews( int imageNum,String theme,String intro,int visNum, String time){
this.imageNum=imageNum;
this.intro=intro;
this.theme=theme;
this.time=time;
this.visNum=visNum;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="16dp" />
<solid android:color="#FFFFFF" />
</shape>

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
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_height="match_parent">
<LinearLayout
android:layout_width="334dp"
android:layout_height="150dp"
android:layout_marginLeft="18dp"
android:background="@drawable/background"
android:elevation="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="11dp"
tools:ignore="MissingConstraints">
<TextView
android:id="@+id/recNews_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="儿童急性B淋巴细胞白血病,除了传统疗法还有哪些前沿治疗方法呢?"
android:textSize="15dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="71dp"
android:orientation="horizontal">
<TextView
android:id="@+id/recNews_intro"
android:layout_width="200dp"
android:layout_height="56dp"
android:layout_marginTop="14dp"
android:text="急性淋巴细胞白血病ALL是儿童最常见的恶性肿瘤其中约85%为
"
android:textSize="11dp" />
<ImageView
android:id="@+id/recNews_image"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
app:srcCompat="@drawable/rec_news1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/recNews_visNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="102"
android:textSize="12dp" />
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="浏览 "
android:textSize="11dp" />
<TextView
android:id="@+id/recNews_time"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="2021-11-6 09:19:54"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
Loading…
Cancel
Save