Android项目实践--高仿微信
asmcvc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
39、微信通讯录联系人快速索引侧边栏SideBar
首先参考《36、微信通讯录页面》中SideBar的布局代码,这里看实现代码:public class SideBar extends View {private char[] l;private SectionIndexer sectionIndexter = null;private ListView list;private TextView mDialogText;private原创 2016-02-25 16:23:11 · 2189 阅读 · 0 评论 -
24、微信-标题栏上的下拉菜单式弹窗TitlePopup
布局:xml version="1.0" encoding="utf-8"?> LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android原创 2016-02-24 13:12:29 · 2752 阅读 · 0 评论 -
25、通用的ViewHolder
以前在适配器中使用ViewHolder的方式如下:private class LeftMenuAdapter extends BaseAdapter {private static final String TAG = "BlackNumberAdapter";@Overridepublic int getCount() {return mLeftMenus.size(); }@Ov原创 2016-02-24 13:23:14 · 775 阅读 · 0 评论 -
26、微信聊天Fragment_Msg的界面布局
界面:布局:xml version="1.0" encoding="utf-8"?>RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_pare原创 2016-02-24 13:24:30 · 1192 阅读 · 0 评论 -
27、微信聊天Fragment_Msg的代码实现
初始化界面时获取所有会话信息,并且创造了一条订阅号信息。根据最后一条消息的时间排序,适配器为NewMsgAdpter,在适配器显示列表项内容时,通过getMessageDigest来获取消息的摘要,也就是不点开看具体消息时的预览消息。继续回到Fragment_Msg的onItemClick,会判断当前点击的消息类型,如果是订阅号消息则打开PublishMsgListActivity原创 2016-02-24 13:25:21 · 2242 阅读 · 0 评论 -
28、新消息界面布局与适配器NewMsgAdpter
预览图:布局代码:xml version="1.0" encoding="utf-8"?>LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"a原创 2016-02-24 13:26:11 · 917 阅读 · 0 评论 -
29、下拉刷新组件SwipeLayout
可以使用com.daimajia.swipelayout库:dependencies { compile 'com.android.support:support-v4:20.+' compile "com.daimajia.swipelayout:library:1.1.7@aar"}参考:http://hao.jobbol原创 2016-02-24 13:26:58 · 914 阅读 · 0 评论 -
30、微信-表情相关
package com.example.wechat.chat;import android.content.Context;import android.graphics.drawable.Drawable;import android.text.Spannable;import android.text.style.ImageSpan;import com.example.wechat.R;i原创 2016-02-24 13:27:29 · 794 阅读 · 1 评论 -
31、Pattern
java的正则表达式匹配类,使用先编译后查找匹配。编译:Pattern.compile(Pattern.quote(smile))匹配:matcher详细使用搜索吧。原创 2016-02-25 16:18:19 · 611 阅读 · 0 评论 -
32、使用Spannable对TextView设置复合文本
使用Spannable对TextView设置复合文本,Spannable对文字的编辑减少TextView的拼接并且达到改变一串字符中的部分文字的字体颜色,背景颜色,字体大小,样式 增加文字的超链接。参考:http://blog.csdn.net/g475266696/article/details/7668988原创 2016-02-25 16:18:43 · 532 阅读 · 0 评论 -
33、FinalDb - afinal库
在UserUtils中有一个操作数据库的类,使用起来很是方便:FinalDb db = FinalDb.create(context, Constants.DB_NAME, false);if (db.findById(user.getId(), User.class) != null) db.deleteById(User.class, user.getId());db.save(us原创 2016-02-25 16:19:06 · 639 阅读 · 0 评论 -
34、JsonUtils
在UserUtils中有一个操作Json的类:user = JSON.parseObject(jsondata, User.class);该JSON类在JsonUtils.jar中,因为Android中操作json的类有很多,不再细述,知道有该库即可。原创 2016-02-25 16:19:25 · 837 阅读 · 0 评论 -
35、公众号(订阅号)消息列表
因为公众号(订阅号)的消息是在聊天界面作为一条集中显示的,点开会又有出现一个新的列表页面,不过大致应与上层列表视图差不多。涉及到一个适配器PublishMsgAdpter和一个点开具体消息的页面PublishMsgDetailActivity,而PublishMsgDetailActivity需要显示具体的消息内容列表,仍然需要一个适配器PublishMsgDetailAdpt原创 2016-02-25 16:19:43 · 2227 阅读 · 0 评论 -
36、微信通讯录页面
界面:整体是一个ListView用来显示联系人列表,右侧是一个侧边栏,用来显示联系人姓名前的首字母,也就是#,A,B,C...Z布局代码:xml version="1.0" encoding="utf-8"?>LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android原创 2016-02-25 16:21:13 · 1642 阅读 · 0 评论 -
37、微信通讯录联系人列表适配器ContactAdapter
联系人列表项的布局:xml version="1.0" encoding="utf-8"?>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:ori原创 2016-02-25 16:22:19 · 3596 阅读 · 0 评论 -
38、微信通讯录联系人汉语拼音中英文混合排序
拼音相关的:按拼音排序以及中文转拼音一个拼音相关的开源库:pinyin4j.jarpublic class PinyinComparator implements Comparator {@Overridepublic int compare(Object arg0, Object arg1) {// 按照名字排序User user0 = (User) arg0;原创 2016-02-25 16:22:38 · 2072 阅读 · 0 评论 -
23、微信-温馨提示对话框WarnTipDialog
这个类重用性蛮好的,以后可以直接借鉴使用。布局:xml version="1.0" encoding="utf-8"?>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height原创 2016-02-24 13:11:29 · 2311 阅读 · 0 评论 -
40、微信-搜索好友及公众号页面SearchActivity
布局比较简单,主要是一个网页:LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="原创 2016-03-14 13:35:21 · 1452 阅读 · 1 评论 -
41、微信-添加新朋友NewFriendsListActivity
使用的是通用的activity_listview布局,但是增加了一个列表头:layout_head = getLayoutInflater().inflate(R.layout.layout_head_newfriend, null);mlistview.addHeaderView(layout_head);mlistview.setAdapter(new NewFriendsAdap原创 2016-03-14 13:36:20 · 1749 阅读 · 0 评论 -
42、微信-添加新朋友列表适配器
xml version="1.0" encoding="utf-8"?>LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="ver原创 2016-03-14 13:37:21 · 1344 阅读 · 0 评论 -
43、微信-好友详情页面FriendMsgActivity
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="#e原创 2016-03-14 13:38:17 · 1708 阅读 · 0 评论 -
44、公共页面PublicActivity
public class PublicActivity extends BaseActivity implements View.OnClickListener {private TextView txt_title;private ImageView img_back;@Overridepublic void onCreate(Bundle savedInstanceState) {原创 2016-03-14 13:38:36 · 777 阅读 · 0 评论 -
45、微信-从通讯录添加好友
页面布局仍然使用通用的activity_listview,通过网络获取联系人:@Overrideprotected void initView() { getLoadingDialog("正在获取联系人").show(); String str_contact = Utils.getValue(this, Constants.ContactMsg); RequestP原创 2016-03-14 13:39:03 · 2065 阅读 · 0 评论 -
55、扫一扫后付款SetMoneyActivity
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="#f原创 2016-05-09 10:47:01 · 1640 阅读 · 0 评论 -
56、Html.fromHtml
tv_money.setText(Html.fromHtml(strmoney));参考:http://www.cnblogs.com/moonvan/archive/2011/04/15/2017041.html原创 2016-05-09 10:47:25 · 514 阅读 · 0 评论 -
57、微信-我Fragment_Profile
xml version="1.0" encoding="utf-8"?>LinearLayoutandroid:gravity="center_horizontal"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="htt原创 2016-05-09 10:48:22 · 1146 阅读 · 0 评论 -
58、微信-我-我的二维码MyCodeActivity
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:ba原创 2016-05-09 10:49:00 · 1576 阅读 · 0 评论 -
59、微信-我-设置SettingActivity
xml version="1.0" encoding="utf-8"?>LinearLayoutandroid:gravity="center_horizontal"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="htt原创 2016-05-09 10:49:38 · 2130 阅读 · 0 评论 -
60、微信-聊天页面ChatActivity
包括聊天消息适配器MessageAdapter在内,这个比较复杂,主要是消息的类型比较多:文字,图片,位置,语音,视频,文件。原创 2016-05-09 10:49:55 · 2435 阅读 · 0 评论 -
61、PasteEditText - 自定义的EditText,用来处理复制粘贴的消息
public class PasteEditText extends EditText {private Context context;public PasteEditText(Context context) {super(context);this.context = context; }public PasteEditText(Context context, AttributeSe原创 2016-05-09 10:50:16 · 1323 阅读 · 0 评论 -
62、LruCache图片缓存
public class ImageCache {private ImageCache() {// use 1/8 of available heap sizecache = new LruCache((int) (Runtime.getRuntime().maxMemory() / 8)) {@Overrideprotected int sizeOf(String key, Bitmap val原创 2016-05-09 10:50:37 · 1136 阅读 · 0 评论 -
63、完结
源码参考:https://github.com/huangfangyi/FanXin-based-HuanXin源码参考:https://github.com/huangfangyi/FanXin-based-HuanXin原创 2016-05-09 10:50:59 · 791 阅读 · 0 评论 -
18、登录问题页面:WebViewActivity
在登录页面的右下角有一个“登录遇到问题?”的按钮,点击后显示登录问题页面:这是加载了一个网页,WebViewActivity作为一个通用的网页显示页面,做的蛮不错,以后可以直接拿来用:package com.example.wechat.view;import android.annotation.SuppressLint;import android.app.原创 2016-01-28 19:19:06 · 1487 阅读 · 0 评论 -
4、闪屏后登陆
如果是第一次使用或者是未登陆状态,则显示登录界面。创建登录视图:LoginActivity布局文件:xml version="1.0" encoding="utf-8"?>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="m原创 2016-01-26 16:06:01 · 1010 阅读 · 0 评论 -
5、登录界面布局文件详解
登录界面的布局文件在上一节中已经贴出,此处不再贴出,主要介绍一下里面的内容。主要有三点吧:1、登录按钮的颜色设置:android:background="@drawable/btn_enable_green"内容:xml version="1.0" encoding="utf-8"?>shape xmlns:android="http://schemas.android.com/apk原创 2016-01-26 16:21:20 · 1005 阅读 · 0 评论 -
6、通用类Utils的常用函数
packagecom.example.wechat.common;importandroid.content.Context;importandroid.content.SharedPreferences;importandroid.preference.PreferenceManager;importandroid.util.Log;/***原创 2016-01-26 16:22:15 · 2109 阅读 · 0 评论 -
1、开篇
刚开始学习Android开发的时候是在2013年,那时候eclipse盛行,但是一直习惯不了,遂慢慢摸索使用IntelliJ Idea一步步实现一个学习的DEMO,详见《Android项目实践--手机安全卫士开发》,后面收到一些留言和私信,多是询问源码的,请翻到最后一篇,文章底部注明了源码的下载地址了。回望过去,又过一年,如今Android开发已从eclipse过度到AndroidSt原创 2016-01-26 14:03:05 · 774 阅读 · 0 评论 -
2、创建工程
1、下载AndroidStudio,后简称AS,我使用的版本是1.5,下载安装后更新Android SDK,此处省略。2、运行AndroidStudio,创建Android工程,名称:wechat,Company Domain:example.com,工程保存目录自己设置,点击下一步。3、mini sdk选择14+,也就是4.0以上版本,太低的不再支持,没啥意义。其他的不用勾选,点击下一步原创 2016-01-26 14:17:48 · 717 阅读 · 0 评论 -
8、登录页面的代码
因为是登录界面,所以仍然是需要处理登录的逻辑,同SplashActivity代码类似(参见《4、闪屏后登陆》),这里会在用户点击登录按钮时处理登录的逻辑:case R.id.btn_login: getLogin();break;private void getLogin() { String userName = et_usertel.getText(原创 2016-01-28 19:13:16 · 1088 阅读 · 0 评论 -
9、Activity基类BaseActivity
LoginActivity派生自BaseActivity,后面会有很多页面均继承自BaseActivity,用于做一些统一的处理。例如在onCreate里制定一个流程:@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);context =原创 2016-01-28 19:13:41 · 1056 阅读 · 0 评论
分享