Interface在包含的适配器内部创建一个
methods。在实现适配器时,这些方法将在您的活动中实现,您可以执行所需的任何 *** 作。
public class Adapter extends RecyclerView.Adapter<MyRecycleViewHolder> { public interface Callbacks { public void onButtonClicked(String titleKey); } private Callbacks mCallbacks; public Adapter() { } @Override public MyRecycleViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_details, null); return new MyRecycleViewHolder(v); } @Override public void onBindViewHolder(final MyRecycleViewHolder holder, final int i) { holder.ExpandButton.setonClickListener(new View.onClickListener() { @Override public void onClick(View v) { if (mCallbacks != null) { mCallbacks.onButtonClicked(holder.ProbTitle.getText().toString()); } } }); } @Override public int getItemCount() { return; } public void setCallbacks(Callbacks callbacks) { this.mCallbacks = callbacks; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)