public class AddAtendanceAdapter extends
RecyclerView.Adapter<AddAtendanceAdapter.AttendanceViewHolder> {
public List<Details> dAttendance = Collections.emptyList();
private LayoutInflater inflater;
private static Context context;
private View v;
public AddAtendanceAdapter(Context context, List<Details> dAttendance) {
this.dAttendance = dAttendance;
this.context = context;
inflater = LayoutInflater.from(context);
}
@Override
public AttendanceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.student_item_row,
parent, false);
AttendanceViewHolder pvh = new AttendanceViewHolder(v);
return pvh;
}
@Override
public void onBindViewHolder(AttendanceViewHolder holder, int postions) {
Details details = dAttendance.get(postions);
holder.StudentsName.setText(details.getStudentName());
Glide.with(context)
.load(details.getStudentImage())
.into(holder.stdImg);
}
@Override
public int getItemCount() {
if (dAttendance != null) {
return dAttendance.size();
}
return 0;
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
public static class AttendanceViewHolder extends RecyclerView.ViewHolder {
TextView StudentsName;
CircleImageView stdImg;
private Activity activity;
AttendanceViewHolder(View itemView) {
super(itemView);
StudentsName = (TextView) itemView.findViewById(R.id.txtStdName);
stdImg = (CircleImageView) itemView.findViewById(R.id.stdImg);
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Log.d("juu","hhh");
openBottomSheet(v);
return false;
}
});
}
private void openBottomSheet(View v) {
//View view = activity.getLayoutInflater ().inflate (R.layout.bottom_sheet, null);
// View view = inflater.inflate( R.layout.bottom_sheet, null );
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
View view = inflater.inflate (R.layout.bottom_sheet, null);
TextView txtBackup = (TextView)view.findViewById(R.id.txt_backup);
TextView txtDetail = (TextView)view.findViewById(R.id.txt_detail);
TextView txtOpen = (TextView)view.findViewById(R.id.txt_open);
final TextView txtUninstall = (TextView)view.findViewById( R.id.txt_uninstall);
final Dialog mBottomSheetDialog = new Dialog (context, R.style.MaterialDialogSheet);
mBottomSheetDialog.setContentView (view);
mBottomSheetDialog.setCancelable (true);
mBottomSheetDialog.getWindow ().setLayout (LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
mBottomSheetDialog.getWindow ().setGravity (Gravity.BOTTOM);
mBottomSheetDialog.show ();
txtBackup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"Clicked Backup",Toast.LENGTH_SHORT).show();
mBottomSheetDialog.dismiss();
}
});
txtDetail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"Clicked Detail",Toast.LENGTH_SHORT).show();
mBottomSheetDialog.dismiss();
}
});
txtOpen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"Clicked Open",Toast.LENGTH_SHORT).show();
mBottomSheetDialog.dismiss();
}
});
txtUninstall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"Clicked Uninstall",Toast.LENGTH_SHORT).show();
mBottomSheetDialog.dismiss();
}
});
}
}
}
Android.view.Windowmanager$BadTokenException:无法添加窗口--令牌null不适用于在Android.view.view.viewRootimpl.SetView(viewRootimpl.java:583),在Android.view.WindowmanagerLobal.AddView(WindowmanagerLobal.java:310),在Android.view.WindowmanagerImpl.AddView(WindowmanagerImpl.java:85),在Android.view.WindowmanagerImpl.AddView(WindowmanagerImpl.java:85),在eViewholder.Access$000(addatendanceAdapter.java:80)在in.edsys.teacherapp.adapters.addatendanceAdapter$AttendanceViewholder$1.onlongclick(addatendanceAdapter.java:95)
在适配器类中,可以使用底部工作表对话框或底部工作表对话框片段来显示底部工作表
BottomSheetDialog示例
View view = ((FragmentActivity)context).getLayoutInflater().inflate(R.layout.fragment_bottom_sheet, null);
BottomSheetDialog dialog = new BottomSheetDialog(mContext);
dialog.setContentView(view);
dialog.show();
您还可以使用BottomsheetDialogFragment
public class BottomsheetDialog extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v=inflater.inflate(R.layout.fragment_bottom_sheet,container,false);
return v;
}
}
BottomSheetDialogFragment bottomSheetDialogFragment = new BottomsheetDialog();
bottomSheetDialogFragment.show(((FragmentActivity)mContext).getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
本文向大家介绍Android实现的RecyclerView适配器,包括了Android实现的RecyclerView适配器的使用技巧和注意事项,需要的朋友参考一下 这个适配器我珍藏已久(近两年), 不断看到别人发适配器相关的文章, 但我总觉得没我的好用, 所以今日拿出来分享(宣传)一下, 欢迎各位指正不足. 源码地址: GitHub 功能 无需继承 Adapter, 无需判断 item 类型. 支
Docker 底层的核心技术包括 Linux 上的命名空间(Namespaces)、控制组(Control groups)、Union 文件系统(Union file systems)和容器格式(Container format)。 我们知道,传统的虚拟机通过在宿主主机中运行 hypervisor 来模拟一整套完整的硬件环境提供给虚拟机的操作系统。虚拟机系统看到的环境是可限制的,也是彼此隔离的。这
1、基本架构 Docker 采用了 C/S架构,包括客户端和服务端。 Docker daemon 作为服务端接受来自客户的请求,并处理这些请求(创建、运行、分发容器)。 客户端和服务端既可以运行在一个机器上,也可通过 socket 或者 RESTful API 来进行通信。 Docker daemon 一般在宿主主机后台运行,等待接收来自客户端的消息。 Docker 客户端则为用户提供一系列可执行
我在课堂上做一个Android报警应用程序。警报显示在主活动的RecycerView中,我希望在按下时删除它们。我可以从我设置的警报数据库中清除它,但我不能访问AlarmManager来取消警报,而且PendingIntent的上下文似乎也是错误的。 在最后3行中,context有一个类型不匹配,因为这是一个MyAdapter类型--我不确定我需要在这里放什么,类似于mainActivity.co
本文向大家介绍HashMap的底层实现?相关面试题,主要包含被问及HashMap的底层实现?时的应答技巧和注意事项,需要的朋友参考一下 JDK1.8之前 JDK1.8 之前 底层是 数组和链表 结合在一起使用也就是 链表散列。HashMap 通过 key 的 hashCode 经过扰动函数处理过后得到 hash 值,然后通过 (n - 1) & hash 判断当前元素存放的位置(这里的 n 指的是
谢谢你的任何线索!