简单模拟QQ界面框架。
package com.lixu.qqjiemian; import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
//欢迎界面
public class WelcomActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.welcom); // 计时器
TimerTask timetask = new TimerTask() { @Override
public void run() {
Intent intent=new Intent(WelcomActivity.this, MainActivity.class);
startActivity(intent); }
};
// 设置时间长短
Timer time = new Timer();
time.schedule(timetask, 3000); }
}
package com.lixu.qqjiemian; import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView; public class MainActivity extends Activity implements android.view.View.OnClickListener {
private TextView xiaoxi;
private TextView lianxiren;
private TextView dongtai; private TextView title; private Fragment xiaoxiFragment;
private Fragment lianxirenFragment;
private Fragment dongtaiFragment; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main); title = (TextView) findViewById(R.id.title); xiaoxi = (TextView) findViewById(R.id.xiaoxi);
lianxiren = (TextView) findViewById(R.id.lianxiren);
dongtai = (TextView) findViewById(R.id.dongtai); xiaoxi.setOnClickListener(this);
lianxiren.setOnClickListener(this);
dongtai.setOnClickListener(this); xiaoxiFragment = new XiaoxiFragment();
lianxirenFragment = new LianxirenFragment();
dongtaiFragment = new DongtaiFragment();
// 初始化的界面设置
choose(1);
title.setText(xiaoxi.getText() + " ");
chooseFragment(xiaoxiFragment); } // 设置点击事件
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.xiaoxi:
choose(1); chooseFragment(xiaoxiFragment); title.setText(xiaoxi.getText() + " "); break;
case R.id.lianxiren: choose(2); chooseFragment(lianxirenFragment); title.setText(lianxiren.getText() + " "); break;
case R.id.dongtai: choose(3); chooseFragment(dongtaiFragment); title.setText(dongtai.getText() + " "); break; default:
break;
} } private void choose(int pos) {
switch (pos) {
case 1:
xiaoxi.setTextColor(Color.BLUE);
xiaoxi.setBackgroundColor(Color.GRAY); lianxiren.setTextColor(Color.GRAY);
lianxiren.setBackgroundColor(Color.WHITE); dongtai.setTextColor(Color.GRAY);
dongtai.setBackgroundColor(Color.WHITE); break;
case 2:
lianxiren.setTextColor(Color.BLUE);
lianxiren.setBackgroundColor(Color.GRAY); xiaoxi.setTextColor(Color.GRAY);
xiaoxi.setBackgroundColor(Color.WHITE); dongtai.setTextColor(Color.GRAY);
dongtai.setBackgroundColor(Color.WHITE);
break; case 3:
dongtai.setTextColor(Color.BLUE);
dongtai.setBackgroundColor(Color.GRAY); lianxiren.setTextColor(Color.GRAY);
lianxiren.setBackgroundColor(Color.WHITE); xiaoxi.setTextColor(Color.GRAY);
xiaoxi.setBackgroundColor(Color.WHITE);
break; default:
break;
}
} // 选择不同的Fragment 的方法
private void chooseFragment(Fragment fragment) { FragmentManager fm = this.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.fragment, fragment);
// 提交
ft.commit(); } }
package com.lixu.qqjiemian; import android.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; public class XiaoxiFragment extends Fragment { @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(android.R.layout.simple_list_item_1, null); TextView tv = (TextView) view.findViewById(android.R.id.text1);
tv.setText("消息界面");
tv.setBackgroundColor(Color.RED); return view;
}
}
package com.lixu.qqjiemian; import android.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; public class LianxirenFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(android.R.layout.simple_list_item_1, null); TextView tv = (TextView) view.findViewById(android.R.id.text1);
tv.setText("联系人界面");
tv.setBackgroundColor(Color.GREEN); return view;
}
}
package com.lixu.qqjiemian; import android.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; public class DongtaiFragment extends Fragment{ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(android.R.layout.simple_list_item_1, null); TextView tv = (TextView) view.findViewById(android.R.id.text1);
tv.setText("动态界面");
tv.setBackgroundColor(Color.YELLOW); return view;
} }
xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textColor="#f44336"
android:textSize="30sp" /> <FrameLayout
android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" > <TextView
android:id="@+id/xiaoxi"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="消息"
android:textSize="15sp" /> <TextView
android:id="@+id/lianxiren"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="联系人"
android:textSize="15sp" /> <TextView
android:id="@+id/dongtai"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="动态"
android:textSize="15sp" />
</LinearLayout> </LinearLayout>
<?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" > <ImageView
android:id="@+id/welcom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/welcome" /> </LinearLayout>
manifest:<activity
android:name=".WelcomActivity"
android:label="@string/app_name"
android:noHistory="true" >
android:noHistory="true"写这个点击回退按钮 不回再回到欢迎界面。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lixu.qqjiemian"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity> <activity
android:name=".WelcomActivity"
android:label="@string/app_name"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application> </manifest>
运行效果图:
简单模拟QQ界面框架。的更多相关文章
- WPF简单模拟QQ登录背景动画
介绍 之所以说是简单模拟,是因为我不知道QQ登录背景动画是怎么实现的.这里是通过一些办法把它简化了,做成了类似的效果 效果图 大体思路 首先把背景看成是一个4行8列的点的阵距,X轴Y轴都是距离70.把 ...
- WPF简单模拟QQ登录背景动画(转)
介绍 之所以说是简单模拟,是因为我不知道QQ登录背景动画是怎么实现的.这里是通过一些办法把它简化了,做成了类似的效果 效果图 大体思路 首先把背景看成是一个4行8列的点的阵距,X轴Y轴都是距离70.把 ...
- iOS开发之旅:实现一个APP界面框架
在上一篇博客中,给大家介绍了一下我们传统的 APP 界面框架-标签导航的一些优缺点,在这篇文章中我会来给大家演示,如何用代码去实现这一框架.本次的实现我会分成俩部分来讲,好了闲话少说,接下来进入到开发 ...
- iOS开发——UI进阶篇(十三)UITabBarController简单使用,qq主流框架
一.UITabBarController简单使用 // 程序加载完毕 - (BOOL)application:(UIApplication *)application didFinishLaunchi ...
- 模拟QQ侧滑控件 实现三种界面切换效果(知识点:回调机制,解析网络json数据,fragment用法等)。
需要用到的lib包 :解析json gson包,从网络地址解析json数据成String字符串的异步网络解析工具AsyncHttpClient等 下载地址:点击下载 Xlistview 下拉上拉第三 ...
- swift:用UITabBarController、UINavigationController、模态窗口简单的搭建一个QQ界面
搭建一个QQ界面其实是一个很简单的实现,需要几种切换视图的控制器组合一起使用,即导航控制器.标签栏控制器.模态窗口.其中,将标签栏控制器设置为window的rootViewController,因为Q ...
- WPF案例 (三) 模拟QQ“快速换装"界面
原文:WPF案例 (三) 模拟QQ"快速换装"界面 这个小程序使用Wpf模拟QQ快速换装页面的动画特效,通过使用组合快捷键Ctrl+Left或Ctrl+Right,可实现Image ...
- 分享一个漂亮WPF界面框架创作过程及其源码(转)
本文会作为一个系列,分为以下部分来介绍: (1)见识一下这个界面框架: (2)界面框架如何进行开发: (3)辅助开发支持:Demo.模板.VsPackage制作. 框架源码如下所示. 本文介绍第(1) ...
- 利用phantomjs模拟QQ自动登录
之前为了抓取兴趣部落里的数据,研究了下QQ自动登录. 当时搜索了一番,发现大部分方法都已经失效了,于是准备自己开搞. 第一个想到的就是参考网上已有方案的做法,梳理登陆js的实现,通过其他语言重写.考虑 ...
随机推荐
- mysql 聚集函数需要注意的问题
1.当没有记录的时候,使用聚集函数,会导致出现一条记录,记录的取值都是NULL,如下:mysql> select name from student where name='David';Emp ...
- 抓取oschina上面的代码分享python块区下的 标题和对应URL
# -*- coding=utf-8 -*- import requests,re from lxml import etree import sys reload(sys) sys.setdefau ...
- STM32学习笔记(三) STM32的GPIO的深入学习
STM32的开发学习主要涉及软硬件两个部分的实现,包含众多外设和总线的理解配置.STM32的整个学习曲线并不陡峭,但入门却相当困难,因此在学习之初,多动手实验和测试相当重要,GPIO作为整个STM32 ...
- Java JTable 表格 获取存储路径,文件名 ,导出excel表格
在做计量泵上位机软件时,需要将下位机传上来的数据,存入MYSQL数据库,显示在java 上位机界面上,并能导出至电脑指定位置. 选择存储路径和文件名: // 处理另存文件的菜单 public void ...
- iOS 细碎知识整理
1centerX,即x轴的中点 centery,即y轴的中点
- Python主文件路径和当前模块路径
主执行文件路径sys.argv[0] ...
- 线性表 - 从零开始实现by C++
参考链接:数据结构探险之线性表篇 线性表
- SlideSwitch
//SlideSwitch.java package com.example.hellojni; import android.content.Context; import android.cont ...
- webdriver hangs when get or click
Same times the webdriver hangs when get url or click some link, webdriver executing (get or click) ...
- JSP Scripting Element
There are five different types of scripting elements Scripting Element Example Comment <%-- comme ...