【发布时间】:2019-08-16 08:45:21
【问题描述】:
我仍然卡在这里,我需要帮助我在不同设备上的 Android 应用。
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class Listadapter extends RecyclerView.Adapter<Listadapter.ListViewHolder>{
String[] CourseTitle={"English - Lilly section", "English - Lilly section", "English - Lilly section",
"English - Lilly section", "English - Lilly section", "English - Lilly section",
"English - Lilly section",
"English - Lilly section"};
String[] Section={"Section (A)",
"Section (A)","Section (A)", "Section (A)",
"Section (A)","Section (A)","Section (A)","Section (A)"};
String[] Coursedec={"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum",
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum"};
@NonNull
@Override
public ListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.myrecylce_data,parent,false);
return new ListViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ListViewHolder holder, int position) {
holder.txt1.setText(CourseTitle[position]);
holder.txt2.setText(Section[position]);
holder.txt3.setText(Coursedec[position]);
}
@Override
public int getItemCount() {
return CourseTitle.length;
}
public class ListViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView txt1,txt2,txt3;
public ListViewHolder(@NonNull View itemView) {
super(itemView);
txt1=itemView.findViewById(R.id.tv_onetxt);
txt2=itemView.findViewById(R.id.tv_twotxt);
txt3=itemView.findViewById(R.id.tv_dsc_course);
}
@Override
public void onClick(View view) {
}
}
}
什么都没发生,我不知道我是怎么做到的
【问题讨论】:
标签: android android-studio android-fragments android-recyclerview