Android学习 -- photoGallery应用的创建方法
程序员文章站
2022-05-25 12:29:57
今天的任务为创建photogallery应用,代码如下:
photogalleryactivity.java:
package com.example.a49840.photogallery;...
今天的任务为创建photogallery应用,代码如下:
photogalleryactivity.java:
package com.example.a49840.photogallery; import android.support.v4.app.fragment; public class photogalleryactivity extends singlefragmentactivity { @override protected fragment createfragment() { return photogalleryfragment.newinstance(); } }
fragment_photo_gallery.xml:
phtotgalleryfragment.java:
package com.example.a49840.photogallery; import android.os.asynctask; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v7.widget.gridlayoutmanager; import android.support.v7.widget.recyclerview; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.textview; import java.util.arraylist; import java.util.list; public class photogalleryfragment extends fragment { private recyclerview mphotorecyclerview; public static photogalleryfragment newinstance() { return new photogalleryfragment(); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setretaininstance(true); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.fragment_photo_gallery, container, false); mphotorecyclerview = (recyclerview) v.findviewbyid(r.id.photo_recycler_view); mphotorecyclerview.setlayoutmanager(new gridlayoutmanager(getactivity(), 3)); return v; } }
上一篇: 不玩抖音了
下一篇: MySql开启binlong的代码实现