0.下载个demo,运行个sample,而后就出事了。新浪微博登陆提示"21338 sso package or sign error"html
签名不对。MD5工具根据keystore生成签名的。Demo的签名是用官网的keystore生成的,而此时用的是Android Studio默认的debug.keystore。因此将其替换成新浪提供sample项目的keystore便可。java
1.Toolbar下有阴影。android
其实不算问题,但我就是不想有。。git
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" app:elevation="0dp" android:theme="@style/MyTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/MyTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout>
app:elevation="0dp"
2.如何实现下拉刷新?github
Google已经提供了SwipeRefreshLayout。api
3.上拉加载?app
http://blog.csdn.net/bboyfeiyu/article/details/39935329
ide
4.已经格式化了的时间字符串转换成Date
工具
新浪微博api(http://open.weibo.com/wiki/2/statuses/public_timeline )里,微博的建立时间是返回这样的一串:this
Sun Dec 27 13:45:44 +0800 2015
我想将它转换为Date,以便与当前时间进行比较。
http://blog.csdn.net/fengyuzhengfan/article/details/40164721
构造一个SimpleDateFormat对象
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
用这个对象解析上面这串已经格式化了的时间
String dateString = "Sun Dec 27 13:45:44 +0800 2015"; Date date = sdf.parse(dateString);
但运行结果是
java.text.ParseException: Unparseable date: "Sun Dec 27 13:45:44 +0800 2015"
Google一下
这我的遇到的问题跟我同样,但下面回答的老外说他也是这样写的,但运行没问题。
You need to try SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd"); System.out.println(sdf2.format(sdf.parse("Wed Jun 20 11:01:05 +0800 2012")));prints
2012/06/20You may also need to set an approriate timezone.
Thank you ,I tried your code but it throws java.text.ParseException: Unparseable date: "Wed Jun 20 11:01:05 +0800 2012" – topxebec Jun 20 '12 at 7:05
看看其余相关的问题,发现漏了一个参数。
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy",Locale.US);
这样写,顺利运行。
我猜想+0800这种表示时区的方式是美国的格式。可能不指定这个locale参数,默认就是当前系统的国家参数。因此上面这位stackoverflow的哥们运行没问题。
并且貌似这种格式是标准格式,能够直接这样
Date createAt = new Date(sourceCreateAt);
来得到Date对象。
5. TextView显示HTML元素
新浪微博api(http://open.weibo.com/wiki/2/statuses/public_timeline )里,有一项是表示微博来源
"source"
:
"<a href="
http:
//weibo.com" rel="nofollow">新浪微博</a>"
要显示a标签的内容,而且让textview点击时,会连接到href,Google一下看有没有html的解析器,发现textview自己就支持html的。
http://hunankeda110.iteye.com/blog/1420470
6.圆形头像?
https://github.com/hdodenhof/CircleImageView
7. ?attr/text_body是什么意思?
看AisenWeibo( http://www.oschina.net/news/62549/aisen-5-0-3 )源码,有个地方定义textview风格,点进来是这样的。
style.xml
<style name="TextBody"> <item name="android:textColor">?attr/text_body</item> <item name="android:textSize">16sp</item> </style>
attrs.xml
看到颜色定义成?attr/text_body,继续点进去
<attr name="text_body" format="reference|color"/>
这里只是定义了“text_body”的格式,没有定义具体的值。
Google一下
http://stackoverflow.com/questions/7504967/can-someone-explain-the-attr
The
?attr/menuIconCamera
value means that an icon frommenuIconCamera
attribute of the current theme will be used.There must be a drawable assigned to the
menuIconCamera
attribute somewhere in thethemes.xml
file. If there're two themes with different values of this attribute then actual icon will depend on a theme which is currently used.The
attrs.xml
file is used to define custom attributes. Without this definition compiler will treat unknown attributes as erroneous.
大意是具体的值是在theme.xml定义的,attrs.xml只是定义格式。
也就是说?attr/text_body这种是根据当前的主题来决定具体的值。
8.ListView分隔条?
不但愿ListView的每一个列表项有分隔条。
android:divider="@null"
listview的divider属性设置为@null便可