摘要: 1. 在gradle.build的dependencies中添加RecyclerView需要的包 2. 在布局文件中添加控件RecyclerView. 3.在Activity中找到RecyclerView并设置LayoutManager和Adapter 4. 写Adapter 阅读全文
posted @ 2016-07-10 23:40 亲爱的村姑 阅读(321) 评论(0) 推荐(0)
摘要: Adapter 中的data有多行,但是RecyclerView只显示一行。 原因出在item的layout xml, 用了自动生成的RelativeLayout, 她的默认高度height属性是match_parent,占满了整个屏,改成wrap_content,就能显示所有行的内容了。 阅读全文
posted @ 2016-07-10 23:34 亲爱的村姑 阅读(1902) 评论(0) 推荐(0)
摘要: 当我试图在UI线程(MainActivity)连接网络的时候,运行时抛出异常droid.os.NetworkOnMainThreadException 安卓的官方文档说 The exception that is thrown when an application attempts to perf 阅读全文
posted @ 2016-07-10 21:38 亲爱的村姑 阅读(266) 评论(0) 推荐(0)
摘要: Android app里试图用HttpUrlConnection获取网络连接,忘记在AndroidManifest清单文件里声明需要用到Internet的权限,运行时报此错误。 解决方法 在AndroidManifest.xml中 与Application平级的地方加入 阅读全文
posted @ 2016-07-10 21:37 亲爱的村姑 阅读(13126) 评论(0) 推荐(2)