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 生日广州男生祝福语简短