这款应用是大四实习时候公司不忙空闲时候做的,逼格不高,也不够炫,凑合着还能用吧。关键是通过这次app的编写,学会了一些服务器端知识,以及Android客户端与服务器端的交互知识,对Android界面的布局有了更深的理解与体会了,给我的体会就是:作为程序猿不能眼高手低,不要觉得简单就不去写,真正写起来时候还是会有很多问题,多去写代码,边写边学,理解会更加深刻。
客户端采用的ADT编写(为什么不用Android Studio?Eclipse用的比较习惯,Android Studio还不习惯,下次开发可能就会用Android Studio了)。
服务器端则采用IntelliJ IDEA,框架使用基于注解的SSH框架,服务器也是写这个应用时候现学的,只能算是会用,很多内部详细的也不是很懂。
数据库方面采用了MySQL数据库。服务器不用说,Tomcat。
最后把服务器架设在了阿里云的服务器上面,应用可以联网用,不过指不定哪一天阿里云就到期了,所以暂且先用着吧。(应用现在已经无法联网使用了,阿里云服务器没了,所以现在只能在本地服务器上跑着了)
另外,应用也成功入驻应用宝、豌豆荚、安智市场、360手机助手了,以上应用市场中搜索“瞎扯蛋”就可以搜到了。

下面附上应用的一些截图和代码目录:


代码目录结构:

一、界面编写

我写的界面比较简单,没有啥自定义的view,但要写好一个美观高大上的界面还是要花很多功夫的。就初步来讲,先学好一些控件和五大布局以及一些重要的属性对写好界面来说很重要的。这次通过编写界面,对RelativeLayout理解也更加深刻了,相对布局真的是个神器,多用用能写出很好的布局。

1、登录界面的编写

登录界面代码保存在login.xml中,写的一般,至于椭圆形button和圆角布局之类的可以自己去网上搜下,很多教程,就是比自带的button好看点。

<?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="fill_parent"android:background="@drawable/login_background"android:orientation="vertical" ><RelativeLayout
        android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginRight="15dp"android:layout_marginLeft="15dp"android:layout_marginTop="80dp"android:background="@drawable/background_login_div_bg"android:padding="15dp" ><TextView
            android:id="@+id/tv_login_title"android:layout_width="fill_parent"android:layout_height="wrap_content"android:gravity="center"android:text="留言簿登录"android:textSize="30sp"android:textStyle="bold" /><TextView
            android:id="@+id/tv_login_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/tv_login_title"android:layout_marginTop="20dp"android:text="帐号"android:textStyle="bold" /><EditText
            android:id="@+id/et_login_name"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/tv_login_name"android:layout_marginTop="5dp"android:background="@drawable/edit_style"android:hint="请输入昵称"android:inputType="text"android:singleLine="true" /><TextView
            android:id="@+id/tv_login_password"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/et_login_name"android:layout_marginTop="10dp"android:text="密码"android:textStyle="bold" /><EditText
            android:id="@+id/et_login_password"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/tv_login_password"android:layout_marginTop="5dp"android:background="@drawable/edit_style"android:hint="请输入密码"android:inputType="textPassword"android:singleLine="true" /><Button
            android:id="@+id/btn_login"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_below="@+id/et_login_password"android:layout_marginTop="10dp"android:background="@drawable/btn_style"android:text="登录" /><TextView android:id="@+id/tv_login_regist"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@+id/btn_login"android:clickable="true"android:gravity="right"android:layout_marginTop="15dp"android:textColor="@android:color/holo_red_dark"android:text="没有帐号?点击注册"/></RelativeLayout></LinearLayout>

2、主界面的编写

主界面我是采用Activity+Fragment结合的方式,Activity中编写底部三个Tab的布局,另外编写三个布局作为点击不同Tab键显示的布局。至于其中点击和实现的逻辑在MainActivity.java中,这里注意:动态界面和设置界面是继承自Fragment,而发表动态界面仍然是一个Activity,便于发表之后退出直接返回到MainActivity中去。稍后粘出来。Fragment最终会显示在下面的一个id为content的FrameLayout中。
主界面activity_main.xml的布局如下:

<?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" ><FrameLayout
        android:id="@+id/content"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1" ></FrameLayout><View
        android:layout_width="match_parent"android:layout_height="1dp"android:background="#000000" /><LinearLayout
        android:layout_width="match_parent"android:layout_height="60dp"android:background="#F8F8FF" ><RelativeLayout
            android:id="@+id/news_layout"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1" ><LinearLayout
                android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerVertical="true"android:orientation="vertical" ><ImageView
                    android:id="@+id/news_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:src="@drawable/news_unselected" /><TextView
                    android:id="@+id/news_text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:text="动态"android:textColor="#82858b" /></LinearLayout></RelativeLayout><RelativeLayout
            android:id="@+id/add_layout"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1" ><LinearLayout
                android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerVertical="true"android:orientation="vertical" ><ImageView
                    android:id="@+id/add_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:src="@drawable/add" /><TextView
                    android:id="@+id/add_text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:text="发表"android:textColor="#82858b" /></LinearLayout></RelativeLayout><RelativeLayout
            android:id="@+id/setting_layout"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1" ><LinearLayout
                android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerVertical="true"android:orientation="vertical" ><ImageView
                    android:id="@+id/setting_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:src="@drawable/setting_unselected" /><TextView
                    android:id="@+id/setting_text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:text="设置"android:textColor="#82858b" /></LinearLayout></RelativeLayout></LinearLayout>
</LinearLayout>

MainActivity与三个Fragment交互的实现,使用FragmentTransaction配合FragmentManager展示Fragment,注意点击时候要修改底部的图标颜色和字体颜色,然后将已有的Fragment隐藏,显示点击的Fragment,大概逻辑就是这样,网上也有很多Fragment实现底部导航栏的文章,可以搜索了解下。

package com.example.activity;import com.example.login_regist.R;import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;public class MainActivity extends Activity implements OnClickListener {private Tab_Data_Fragment dataFragment;private Tab_Setting_Fragment settingFragment;private View add_view;private View data_view;private View setting_view;private ImageView img_data;private ImageView img_setting;private TextView tv_data;private TextView tv_setting;private FragmentManager fragmentManager;private Bundle loginBundle;private String userName;private Bundle DataBundle;private Bundle SettingBundle;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubrequestWindowFeature(Window.FEATURE_NO_TITLE);super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initViews();fragmentManager = getFragmentManager();// 第一次启动时选中第0个tabtry {Thread.sleep(1000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}setTabSelection(0);}private void initViews() {add_view = findViewById(R.id.add_layout);data_view = findViewById(R.id.news_layout);setting_view = findViewById(R.id.setting_layout);img_data = (ImageView) findViewById(R.id.news_image);img_setting = (ImageView) findViewById(R.id.setting_image);tv_data = (TextView) findViewById(R.id.news_text);tv_setting = (TextView) findViewById(R.id.setting_text);add_view.setOnClickListener(this);data_view.setOnClickListener(this);setting_view.setOnClickListener(this);// 获取从LoginActivity传过来的用户名,显示在设置里面loginBundle = getIntent().getExtras();DataBundle = new Bundle();SettingBundle = new Bundle();if (loginBundle != null) {userName = loginBundle.getString("userName");if (userName == null) {userName = loginBundle.getString("name");}Log.i("TAG", "穿过来的值为" + userName);} else {Log.i("TAG", "extras为空");}DataBundle.putString("userName", userName);SettingBundle.putString("userName", userName);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.news_layout:Log.i("TAG", "模拟点击了");setTabSelection(0);break;case R.id.add_layout:Intent intent = new Intent();intent.setClass(MainActivity.this, Tab_AddActivity.class);intent.putExtra("name", userName);startActivityForResult(intent, 1);// MainActivity.this.findViewById(R.id.tv_refresh).performClick();break;case R.id.setting_layout:setTabSelection(1);break;default:break;}}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {if (resultCode == -1) {MainActivity.this.findViewById(R.id.tv_refresh).performClick();}}public void setTabSelection(int i) {// 每次选中之前先清除掉上次的选中状态clearSelection();// 开启一个Fragment事务FragmentTransaction transaction = fragmentManager.beginTransaction();// 先隐藏掉所有的Fragment,以防止有多个Fragment显示在界面上的情况hideFragments(transaction);switch (i) {case 0:Log.i("TAG", "单击走的显示流程");// 当点击了消息tab时,改变控件的图片和文字颜色img_data.setImageResource(R.drawable.news_selected);tv_data.setTextColor(Color.BLUE);if (dataFragment == null) {// 如果dataFragment为空,则创建一个并添加到界面上dataFragment = new Tab_Data_Fragment();dataFragment.setArguments(DataBundle);transaction.add(R.id.content, dataFragment);Log.i("TAG", "dataFragment为空");} else {// 如果dataFragment不为空,则直接将它显示出来Log.i("TAG", "dataFragment不为空。。。。。。");// dataFragment.setArguments(DataBundle);transaction.show(dataFragment);}break;case 1:// 当点击了设置tab时,改变控件的图片和文字颜色img_setting.setImageResource(R.drawable.setting_selected);tv_setting.setTextColor(Color.BLUE);if (settingFragment == null) {// 如果settingFragment为空,则创建一个并添加到界面上settingFragment = new Tab_Setting_Fragment();// 从activity传递给Fragment里面去settingFragment.setArguments(SettingBundle);transaction.add(R.id.content, settingFragment);Log.i("TAG", "settingFragment为空。。。。。。");} else {// 如果settingFragment不为空,则直接将它显示出来// settingFragment.setArguments(bundle);transaction.show(settingFragment);Log.i("TAG", "settingFragment不为空。。。。。。");}break;// case 2:// Log.i("TAG", "双击走的刷新流程");// // 当点击了消息tab时,改变控件的图片和文字颜色// img_data.setImageResource(R.drawable.news_selected);// tv_data.setTextColor(Color.BLUE);// dataFragment = null;// // 如果dataFragment为空,则创建一个并添加到界面上// dataFragment = new Tab_Data_Fragment();// dataFragment.setArguments(DataBundle);// transaction.add(R.id.content, dataFragment);//// break;default:break;}transaction.commit();}/*** 清除掉所有的选中状态。*/private void clearSelection() {img_data.setImageResource(R.drawable.news_unselected);tv_data.setTextColor(Color.parseColor("#82858b"));img_setting.setImageResource(R.drawable.setting_unselected);tv_setting.setTextColor(Color.parseColor("#82858b"));}/*** 将所有的Fragment都置为隐藏状态。* * @param transaction*            用于对Fragment执行操作的事务*/private void hideFragments(FragmentTransaction transaction) {if (dataFragment != null) {transaction.hide(dataFragment);}if (settingFragment != null) {transaction.hide(settingFragment);}}
}

先说下布局吧,下面的博客再说说服务器端怎么写的,再介绍下客户端和服务器端怎么交互数据的。app客户端和服务端源码链接:链接

仿QQ空间的一款APP(一)相关推荐

  1. 仿QQ空间的一款APP(二)

    接着上面一片博客,这篇主要讲一下服务器怎么写的. 对于服务器方面的知识,其实我也不大了解,以前更是没有学习过SSH框架,之前也没用过IntellJ IDEA这个工具(以前都是用myeclipse的), ...

  2. iOS传感器集锦、飞机大战、开发调试工具、强制更新、Swift仿QQ空间头部等源码

    iOS精选源码 飞机大作战 MUPhotoPreview -简单易用的图片浏览器 image LLDebugTool是一款针对开发者和测试者的调试工具,它可以帮... image 多个UIScroll ...

  3. 【Android UI设计与开发】第09期:底部菜单栏(四)Fragment+PopupWindow仿QQ空间最新版底部菜单栏

    转载请注明出处:http://blog.csdn.net/yangyu20121224/article/details/9023451          在今天的这篇文章当中,我依然会以实战加理论结合 ...

  4. java 仿qq空间_仿QQ空间和微信朋友圈,高解耦高复用高灵活

    先看看效果: 用极少的代码实现了 动态详情 及 二级评论 的 数据获取与处理 和 UI显示与交互,并且高解耦.高复用.高灵活. 动态列表界面MomentListFragment支持 下拉刷新与上拉加载 ...

  5. 高仿QQ空间项目实战开发(带服务器端程序)

    大家好,今天我在这里分享一个小程序.高仿QQ空间的APP,这里给大家分享一个安卓APP和PHP写的服务器程序.想提高安卓开发能力或安卓和后台服务器一起做的初学者值得一看,老鸟跳过. 接下来我们看看效果 ...

  6. Android仿QQ空间底栏

    继上一篇仿新浪微博底栏,我们在写个仿QQ空间底栏的效果. 先看主布局文件: <RelativeLayout xmlns:android="http://schemas.android. ...

  7. Android仿QQ空间底部菜单

    之前曾经在网上看到Android仿QQ空间底部菜单的Demo,发现这个Demo有很多Bug,布局用了很多神秘数字.于是研究了一下QQ空间底部菜单的实现,自己写了一个,供大家参考.效果如下图所示:  点 ...

  8. android写qq动态界面,Android_Android仿QQ空间主页面的实现,今天模仿安卓QQ空间,效果如 - phpStudy...

    Android仿QQ空间主页面的实现 今天模仿安卓QQ空间,效果如下: 打开程序的启动画面和导航页面我就不做了,大家可以模仿微信的那个做一下,很简单.这次主要做一下主页面的实现,下面是主页面的布局: ...

  9. java仿qq空间音乐播放_完美实现仿QQ空间评论回复特效

    评论回复是个很常见的东西,但是各大网站实现的方式却不尽相同.大体上有两种方式 1. 像优酷这种最常见,在输入框中@要回复的人,这种方式下,用www.cppcns.com户可以修改@. 新浪微博则是在这 ...

最新文章

  1. 云服务干掉的是运维。
  2. jQuery弹出窗口浏览图片
  3. 二层交换机的六条安全秘诀
  4. vuecli3修改html,详解vue-cli3多页应用改造
  5. if/ else 你真的会吗?
  6. 这是要把前几年积累的C++的节操给丢光吗
  7. Linear world POJ - 2674(弹性碰撞+技巧)
  8. wince6.0中文内核定制
  9. 虚拟机同步器用易语言怎么写_安装虚拟机的好处或用处是什么/如有效地防止病毒...
  10. RK3566-LPDDR4-EVB EDP屏幕调试
  11. 好像有点看不懂,脑洞
  12. 三國演義與三國志兩部文本的導讀概要2019年5月11日
  13. 导出word功能,用html代码在word中插入分页符
  14. 实用一位加法电路-全加器(全加器真值表、全加器的逻辑组合电路)、几种基本组合逻辑电路真值表 补充:逻辑电路基础:与门、或门、非门----计算机组成原理
  15. 去除 WPS 的广告
  16. Hexo站点SEO优化攻略
  17. 光纤验收测试标准、参数及常用设备
  18. 部门换届推文文字_第十五届院级学生干部换届大会火热进行中
  19. android弹出确认对话点击取消,Android点击返回按钮弹出确认消息对话框
  20. “蚁族”们的生存状态

热门文章

  1. centos7安装mysql57--实际操作可行
  2. 常用企业微信开源SCRM对比
  3. Python:11设计动物Animal类,该类包括颜色color属性与叫call方法。再设计鱼Fish类,包括.....
  4. svn安装并用eclipse集成
  5. SaaS-HRM中的权限设计
  6. Android JSONObject把URL转义了
  7. Barbara Liskov:CLU与Argus语言发明人
  8. Windows更新策略配置
  9. Windows 更新安装更新时,可能会收到“更新失败。安装一些更新时出现问题,且错误为:0x80073701,0x800f0988解决方案
  10. 这篇文章几乎回答了你对量化对冲的所有疑问