模拟设计与实现手机微信APP或QQ APP系统,具体要求:?
1)??登陆界面使用SharedPreference记住密码和账号。
2)??主界面包含顶部选项菜单、底部导航菜单
3)??使用RecyclerView显示页码主要内容
4)????不同页面之间可以导航和跳转
5)??可以模拟发送消息、添加、搜索好友等
6)??使用SQLite保存主要数据信息
7) ?写WORD报告介绍系统功能结构、设计类、数据库表、界面效果截图等。
- 程序设计
1.模块设计
设计六个模块
分别为:注册,登陆,首页,通讯录,发现,我,个人信息,更多。
2.界面设计
本程序主要设计六个界面为:注册界面,登陆界面,首页,消息界面,笔记界面,我的界面。
给界面设计图如图1,图2,图3,图4,图5,图6,图7所示。
?
图 2注册界面设计图
图 3登陆界面设计图
?
?
图 4首页界面设计图
?
?
图 5通讯录界面设计图
?
图 6发现界面设计图
?
图 7发现界面设计图
图 8个人信息界面设计图
?
?
图 9更多 信息界面设计图
?
图 10发送信息界面设计图
?
- 核心程序代码
?注册界面代码:
?
@Override
public void onClick(View view) {
??????switch (view.getId()){
??????????case R.id.img_back:
??????????????Utils.finish(RegisterActivity.this);
??????????????break;
??????????case R.id.btn_send:
???????????????if (mc == null) {
???????????????????mc = new MyCount(60000, 1000); //第一个参数是总的时间,第二个参数是间隔时间
???????????????}
???????????????????break;
??????????case R.id.btn_register:
??????????????startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
??????????????overridePendingTransition(R.anim.push_up_in,R.anim.push_up_out);
??????????????Toast.makeText(this,"注册成功",Toast.LENGTH_SHORT).show();
??????????????break;
??????????default:
??????????????break;
??????}
}
登陆界面代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
????super.onCreate(savedInstanceState);
????setContentView(R.layout.wechat_login);
????//获取实例对象
????sp = this.getSharedPreferences("userinfo", Context.MODE_PRIVATE);
????initControl();
????initData();
????initView();
????setListener();
????//监听记住密码多选框按钮事件
????mermorize_password.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
????????@Override
????????public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
????????????if (mermorize_password.isChecked()){
????????????????System.out.println("记住密码已选中");
????????????????sp.edit().putBoolean("ISCHECK",true).commit();
????????????}else{
????????????????System.out.println("记住密码未选中");
????????????????sp.edit().putBoolean("ISCHECK",false).commit();
????????????}
????????}
????});
????//监听自动登录多选框按钮事件
????auto_login.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
????????@Override
????????public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
????????????if (auto_login.isChecked()){
????????????????System.out.println("自动登录已选中");
????????????????sp.edit().putBoolean("AUTO_ISCHECK",true).commit();
????????????}else{
????????????????System.out.println("自动登录未选中");
????????????????sp.edit().putBoolean("AUTO_ISCHECK",false).commit();
????????????}
????????}
????});
}
首页代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
????super.onCreate(savedInstanceState);
????ActivityCollector.add(this);
????setContentView(R.layout.wechat_chat);
???initControls();
}
????@Override
????public void onBackPressed() {
????????Intent intent ?=new Intent();
????????if (chatEditView.getText().toString() != null){
????????????intent.putExtra("msg",chatEditView.getText().toString());
????????????intent.putExtra("friend",friend);
????????}
????????setResult(10,intent);
????????finish();
????}
????/**
?????* 插入数据
?????*/
????private void initMessage() {
????????String name = getIntent().getStringExtra("friend");
????????if (name.equals("小李")){
????????????News message1 = new News(0,"吃饭了吗?", BitmapFactory.decodeResource(getResources(),R.drawable.image1));
????????????newsArrayList.add(message1);
????????}
????????else if(name.equals("小芳")){
????????????News message1 = new News(0,"天天开心哈,祝你安卓老师问的都对哈", BitmapFactory.decodeResource(getResources(),R.drawable.image2));
????????????newsArrayList.add(message1);
????????}
????????else if(name.equals("小文")){
????????????News message1 = new News(0,"有空一起出来聚聚呗", BitmapFactory.decodeResource(getResources(),R.drawable.image3));
????????????newsArrayList.add(message1);
????????}
????????else if(name.equals("张凡")){
????????????News message1 = new News(0,"你今天过的怎麽样", BitmapFactory.decodeResource(getResources(),R.drawable.image4));
????????????newsArrayList.add(message1);
????????}
????}
????@Override
????public void onClick(View view) {
????????switch (view.getId()) {
????????????case R.id.img_back:
????????????????Intent intent = new Intent(ChatActivity.this, WeixinFragment.class);
????????????????overridePendingTransition(R.anim.push_left_in,R.anim.push_left_out);
????????????????startActivity(intent);
????????????????break;
????????????default:
????????????????break;
????????}
????}
????@Override
????protected void onDestroy() {
????????super.onDestroy();
????????ActivityCollector.remove(this);
????}
}
发消息界面代码:
?//3.创建ViewHolder
????@NonNull
????@Override
????public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
????????//将条目布局文件填充成View对象
????????View itemView= View.inflate(parent.getContext(),R.layout.wechat_message,null);
????????ViewHolder holder=new ViewHolder(itemView);
????????return holder;
????}
????//4.给相应ViewHolder中的控件设置数据内容
????//数据从List中第position个元素中拿到
????@Override
????public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
????????final Message msg=msgList.get(position);
????????holder.iv_head.setImageResource(msg.getImg_head());
????????holder.friend.setText(msg.getFriend());
????????holder.message.setText(msg.getMsg());
????????holder.time.setText(msg.getTime());
????????holder.itemView.setOnClickListener(new View.OnClickListener() {
????????????@Override
????????????public void onClick(View view) {
????????????????Intent intent=new Intent(view.getContext(), ChatActivity.class);
????????????????intent.putExtra("friend",msg.friend);
????????????????((Activity)view.getContext()).startActivityForResult(intent,1);
????????????}
????????});
????????holder.iv_head.setOnClickListener(new View.OnClickListener() {
????????????@Override
????????????public void onClick(View view) {
????????????????Toast.makeText(view.getContext(),
????????????????????????"你点击了"+msg.getFriend()+"头像", Toast.LENGTH_SHORT).show();
????????????}
????????});
????}
????//5.获取条目个数=List元素个数
????@Override
????public int getItemCount() {
????????return msgList.size();
????}
}
我的界面代码:
????@Override
????protected void onCreate(Bundle savedInstanceState) {
????????super.onCreate(savedInstanceState);
????????setContentView(R.layout.wechat_myinfo);
??????RelativeLayout myinfo_more = ?findViewById(R.id.re_temp_more);
????????myinfo_more.setOnClickListener(new View.OnClickListener() {
????????????@Override
????????????public void onClick(View view) {
???????????????startActivity(new Intent(MyInfoActivity.this,MyInfoMoreActivity.class));
????????????}
????????});
????}
}
- 结果示意图
结果示意图如图8,图9所示。
?
图 8 添加好友功能实现
?
图 9 搜索好友界面
???????源码见主页
|