Call a Fragment method from an Adapter

前端 未结 3 451
长发绾君心
长发绾君心 2020-12-07 20:24

I have a method sendData() in my fragment. This method starts a new Activity. I want to call this method from my ArrayAdapter.

Here is my c

3条回答
  •  醉酒成梦
    2020-12-07 21:02

    You can make sendData method as static

    public static void sendData(int position)
    {
         ......
    }
    

    n call it as

    @Override
    public void onClick(View v) 
    {
         // TODO Auto-generated method stub
         HomeFragment.sendData(position)
         ........    
    }
    

提交回复
热议问题