mymoni3——具体代码~添加权限依赖 + 页面布局 + 封装类、工具类
来源:互联网 发布:谢津死亡真相知乎 编辑:程序博客网 时间:2024/05/22 06:26
添加权限依赖
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><applicationandroid:name=".MyApp"
compile 'com.github.userswlwork:pull-to-refresh:1.0.0'compile 'com.google.code.gson:gson:2.2.4'compile 'com.android.support:design:26+'compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'compile 'com.jakewharton:butterknife:8.8.1'annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'页面布局
activity_main:
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayout android:id="@+id/drawer" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/line" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:id="@+id/fl" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" ></FrameLayout> <RadioGroup android:id="@+id/rg" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:id="@+id/rb1" android:layout_width="0dp" android:layout_weight="1" android:layout_marginLeft="50dp" android:layout_height="wrap_content" android:text="首页" android:button="@null"/> <RadioButton android:id="@+id/rb2" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:text="发现" android:button="@null"/> <RadioButton android:id="@+id/rb3" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:text="下载" android:button="@null"/> <RadioButton android:id="@+id/rb4" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:text="我的" android:button="@null"/> </RadioGroup> </LinearLayout> <ImageView android:id="@+id/img" android:layout_width="100dp" android:layout_height="match_parent" android:layout_gravity="left" android:choiceMode="singleChoice" android:background="#33ff99" android:src="@mipmap/ic_launcher_round"/></android.support.v4.widget.DrawerLayout>f1:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.TabLayout android:id="@+id/f1_tab" android:layout_width="match_parent" android:layout_height="wrap_content" /> <android.support.v4.view.ViewPager android:id="@+id/f1_vp" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>f2:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff68"> <TextView android:id="@+id/f2_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="我是F2碎片的tv"/></LinearLayout>f01:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"><android.support.v4.view.ViewPager android:id="@+id/f01_vp" android:layout_width="match_parent" android:layout_height="120dp"></android.support.v4.view.ViewPager> <com.handmark.pulltorefresh.library.PullToRefreshListView android:id="@+id/f01_pull" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"></com.handmark.pulltorefresh.library.PullToRefreshListView></LinearLayout>f02:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f89"> <com.handmark.pulltorefresh.library.PullToRefreshGridView android:id="@+id/f02_pull" android:layout_width="match_parent" android:layout_height="match_parent"></com.handmark.pulltorefresh.library.PullToRefreshGridView>ullToRefreshGridView</LinearLayout>item1:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/item_img" android:layout_width="100dp" android:layout_height="100dp" android:layout_marginLeft="20dp"/><TextView android:id="@+id/item_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginTop="15dp"/></LinearLayout>NetUtil
public class NetUtil { private static String tag = "getNetJson"; public static String getNetJson(String urlString) { try { //url对象封装接口字符串 URL url = new URL(urlString); //用url打开连接, 返回值我们用HttpURLConnection HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setConnectTimeout(8000);//设置链接超时时间 int responseCode = urlConnection.getResponseCode(); //获取状态码 if (responseCode == 200) { InputStream inputStream = urlConnection.getInputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); //可拼接的字符串 StringBuilder stringBuilder = new StringBuilder(); String temp = ""; while ((temp = bufferedReader.readLine()) != null) { stringBuilder.append(temp); } String jsonString = stringBuilder.toString(); return jsonString; } else { } } catch (MalformedURLException e) { e.printStackTrace(); Log.e(tag, "getNetJson: " + e.toString()); } catch (IOException e) { e.printStackTrace(); Log.e(tag, "getNetJson: " + e.toString()); } return ""; }}MyApp
public class MyApp extends Application { File cacheFile= new File(Environment.getExternalStorageDirectory()+"/"+"imgages"); @Override public void onCreate() { super.onCreate(); //初始化组件,链式开发思想,整个框架的参数初始化配置 ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this) .memoryCacheExtraOptions(480, 800) // default = device screen dimensions 内存缓存文件的最大长宽 .diskCacheExtraOptions(480, 800, null) // 本地缓存的详细信息(缓存的最大长宽),最好不要设置这个 .tasksProcessingOrder(QueueProcessingType.FIFO) // default .denyCacheImageMultipleSizesInMemory() .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) //可以通过自己的内存缓存实现 .memoryCacheSize(2 * 1024 * 1024) // 内存缓存的最大值 .memoryCacheSizePercentage(13) // default .diskCacheSize(50 * 1024 * 1024) // 50 Mb sd卡(本地)缓存的最大值 .diskCacheFileCount(100) // 可以缓存的文件数量 .diskCache(new UnlimitedDiskCache(cacheFile))//自定义缓存目录 // default为使用HASHCODE对UIL进行加密命名, 还可以用MD5(new Md5FileNameGenerator())加密 .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .writeDebugLogs() // 打印debug log .build(); ImageLoader.getInstance().init(configuration); }}ImageLoaderUtils_circle
public class ImageLoaderUtils_circle { public static DisplayImageOptions getDisplayImageOption() { DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true)//设置下载的图片是否缓存在内存中 .cacheOnDisk(true) .displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少 .build();//构建完成 return options; }}
阅读全文
0 0
- mymoni3——具体代码~添加权限依赖 + 页面布局 + 封装类、工具类
- mymoni3——具体代码~添加权限依赖 + 页面布局 + 封装类、工具类
- mymoni3——具体代码~Activity类 + Fragfment类 的具体逻辑代码(+外部类MAsyncTask)
- mymoni3——具体代码~Activity类 + Fragfment类 的具体逻辑代码(+外部类MAsyncTask)
- mymoni3——实现效果:
- OkHttpUtils已封装好的工具类+依赖,直接使用
- JS常用代码工具封装类整理
- 常用工具类、依赖、权限
- oracle数据库的连接——封装工具类(代码)
- 封装通用分页工具,通过反射指定具体的实现类
- 代码权限和依赖
- 工具类——吐司ToastUtils封装
- 侧拉——我的相册—权限。依赖。布局
- android开发 系统信息相关工具类 权限管理页面
- java关机工具之页面布局参考代码
- 与具体ORM实现无关的属性过滤条件封装类, 主要记录页面中简单的搜索过滤条件.
- jdbc封装工具类
- Calendar封装工具类
- java 设计模式 策略模式
- 【JavaScript学习】DOM:DocumentFragment类型
- gulp-css-wrap工具的使用——[批量为css文件扩展命名空间]
- 中国知名个人站长排行TOP91
- ajax
- mymoni3——具体代码~添加权限依赖 + 页面布局 + 封装类、工具类
- 银行卡号识别Bank Card Rec 主要功能接口说明
- HBase 常用操作
- matlab Wavedec.函数
- windows 训练、微调caffenet 训练测试自己的数据
- HDU 1254 推箱子(广搜+优先队列)
- Drools7.5.0教程(4)-workbench之项目创建
- android:MVP网络请求数据,运用RecyclerView-LinearLayout展示
- POJ 1265 (Pick 公式+求任意多边形面积+顶点多边形的边整点个数)