如何在android中调用片段类中的静态方法?

时间:2015-01-09 09:29:02

标签: android

public static void edit(String vid, String vnames, String rowid) {
        // TODO Auto-generated method stub

        Fragment fragment = new AddVendor();
        bundle = new Bundle();
        bundle.putString("vendorid", vid);
        bundle.putString("rowid", rowid);
        bundle.putBoolean("main", true);
        Log.e("2", "" + vid);
        Log.e("22", "" + rowid);
        Log.e("33", "" + vnames);

    fragment.setArguments(bundle);
    FragmentManager fragmentManager=getSupportFragmentManager();
        // FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.frame_container, fragment, CommonUtil.CLASS_NAME)
                .commit();
        //add();
    }

fragmentmanager显示静态方法不支持错误。如何调用片段?

1 个答案:

答案 0 :(得分:0)

  

如何在android中的片段类中调用静态方法?

您可以通过edit类型FragmentManager方法中再添加一个参数来实现此目的:

public static void edit(String vid, String vnames, 
                     String rowid,FragmentManager fragmentManager) { 
       // use fragmentManager for transaction
     ....
}