How to call a fragment from BaseAdapter Class Android?

前端 未结 7 666
走了就别回头了
走了就别回头了 2020-12-17 03:38

I want to call a Fragement from my BaseAdapter Class. In this class I have button on click of which I want to call the new fragment, but I am not able to get this. I have to

7条回答
  •  青春惊慌失措
    2020-12-17 03:49

    Easiest way: Do in Fragment

    Adapter a = new Adapter(arg,Fragment.this);// or only this. This will pass the fragment object to the adapter.
    

    and in Adapter

    v.ckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    
    
                if(fragment!=null)
                    fragment.ValidateList();// call any public method of the fragment
                }
            });
    

提交回复
热议问题