如何将Fragment代码转换为Activity代码

时间:2017-05-16 20:50:15

标签: android android-layout android-fragments

我想将此片段转换为活动请帮助我!

公共类MenuCategoryFragment扩展Fragment {

private static final String TAG = MenuCategoryFragment.class.getSimpleName();

private RecyclerView recyclerView;

public MenuCategoryFragment() {
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getActivity().setTitle(getString(R.string.manu_categories));
    View view = inflater.inflate(R.layout.fragment_menu_category, container, false);

    recyclerView = (RecyclerView)view.findViewById(R.id.food_menu);
    GridLayoutManager mGrid = new GridLayoutManager(getActivity(), 2);
    recyclerView.setLayoutManager(mGrid);
    recyclerView.setHasFixedSize(true);

    return view;
}

}

1 个答案:

答案 0 :(得分:0)

这是您的活动类。

@GET("android/determinace/json/images.json")
fun getImages(): Single<ImagesResponse>

最后一件事,请务必在“AndroidMenifest”中声明您的“活动”类。