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 红包祝福语简短10字
18 周六早晨祝福语简短