接口回调


//适配器中ide

   //定义一个接口
    public interface Onand {
        void shouText(Integer poss);
    }this

    //声明接口变量
    public Onand onand;.net

    //提供方法,暴露接口
    public void setOnand(Onand onand) {
        this.onand = onand;
    }接口


//条目点击事件
    llcont = (LinearLayout) itemView.findViewById(R.id.llcont);
    llcont.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
         onand.shouText(getLayoutPosition());
       }
    });事件

//-----------------------------------------------------    
//Activtiy或者Fragment中get

    //接口回调         
    adapter.setOnand(new MyAdapter.Onand() {
        @Override
        public void shouText(Integer poss) {
    //吐司
               Toast.makeText(getActivity(), list1.get(poss).getData().getSummary(), Toast.LENGTH_SHORT).show();
              }
        });it

相关文章
相关标签/搜索