StudyTimeXrcAdapter.java
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.hh.xuetubao.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hh.xuetubao.R;
import java.util.List;
public class StudyTimeXrcAdapter extends RecyclerView.Adapter<StudyTimeXrcAdapter.ViewHolder> {
private Context context;
private List<String> day;
private List<String> time;
public StudyTimeXrcAdapter(Context context, List<String> day, List<String> time) {
this.context = context;
this.day = day;
this.time = time;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.rc_read_time, null);
View viewById = view.findViewById(R.id.view_long);
ViewGroup.LayoutParams params = viewById.getLayoutParams();
int height = params.height;
params.height = 1200;
viewById.setLayoutParams(params);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
if (day.get(position) != null)
holder.tvDay.setText(time.get(position));
if (time.get(position) != null)
holder.tvTime.setText(day.get(position));
ViewGroup.LayoutParams params = holder.longView.getLayoutParams();
Log.e("SSsss",day.get(position)+"");
int a= Integer.valueOf(day.get(position).substring(day.get(position).length()-1,day.get(position).length()));
Log.e("a_Position",a+"");
params.height = a * 50;
if(a == 0){
holder.longView.setVisibility(View.GONE);
}else {
holder.longView.setLayoutParams(params);
}
// params.height = 100;
}
@Override
public int getItemCount() {
return day.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final TextView tvDay;
private final TextView tvTime;
private final View longView;
public ViewHolder(View itemView) {
super(itemView);
tvDay = (TextView) itemView.findViewById(R.id.tv_day);
tvTime = (TextView) itemView.findViewById(R.id.tv_time);
longView = itemView.findViewById(R.id.view_long);
}
}
}