Android中给fragment写入参数的轻量开发包FragmentArgs简介
Android开发有时候会令人头痛。你不得不为诸如建立fragment这样简单的事情写很多代码。幸运的是java支持一个强大的工具:注释处理器(AnnotationProcessors)。
Fragment的问题是你不得不设置很多参数,从而让它正常运行。很多android开发新手通常这样写:
publicclassMyFragmentextendsFragment
{
privateintid;
privateStringtitle;
publicstaticMyFragmentnewInstance(intid,Stringtitle) { MyFragmentf=newMyFragment(); f.id=id; f.title=title; returnf; }
@Override publicViewonCreateView(LayoutInflaterinflater,ViewGroupcontainer, BundlesavedInstanceState) { Toast.makeText(getActivity(),"Hello"+title.substring(0,3), Toast.LENGTH_SHORT).show(); } }
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短