Big Bug Ban

兴趣 践行 创新

Android开发日志 制作一个欢迎界面

 

一个友好的欢迎界面对用户来说体验会非常棒的

下面我讲用一个实例 讲解schoolpaper的欢迎界面的制作

最终的目的是有一个进度条 还有一个tips变化

1.首先 建立一个android工程

2.制作一个界面  我使用的droiddraw来制作的xml

然后你还需要一个图,作为整个的背景图

下面是我生成的xml   只能用于HVGA屏幕的哈~

 <?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : main.xml
    Created on : 2010年10月19日, 上午8:47
    Author     : princehaku
    Description:
        欢迎界面的布局
-->
<AbsoluteLayout
android:background="@drawable/welcome"
android:id="@+id/widget39"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/tips"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
    android:text="please wait"
android:gravity="center"
android:layout_x="0px"
android:layout_y="329px"
>
</TextView>
<ProgressBar
android:id="@+id/loading"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="160px"
android:progress="100"
android:layout_height="wrap_content"
android:layout_x="80px"
android:layout_gravity="center_vertical"
android:layout_y="257px"
>
</ProgressBar>
</AbsoluteLayout>

 

注意其中的android:background=”@drawable/welcome”

需要找一个图 放在res drawble 命名为welcome.png的图片 作为背景图

3.开始敲代码吧..

首先需要在MainActivity 加入三个静态成员
/**进度条的进度
*
*/
static int idx=0;
/**进度条
*
*/
protected ProgressBar myProgressBar;
/**提示文本
*
*/
protected TextView tips;
还有一个,我们的Handler~

private Handler process=new HandlerWelcomeProc(this);
之所以要加这个 是为了在进程里面处理主界面的变化,这个android的进程安全的机制有关

这个类的内容如下

 /*  Copyright 2010 princehaku
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  Created on : 2010-11-8, 14:10:39
 *  Author     : princehaku
 */

package net.techest.lamp;

import android.app.Activity;
import android.os.Handler;
import android.os.Message;

/**处理欢迎界面的proc消息
 *
 * @author princehaku
 */
 class HandlerWelcomeProc extends Handler {

        private static Activity res;

        public HandlerWelcomeProc(Activity aThis) {
             this.res = aThis;
        }
        @Override
        public void handleMessage(Message msg) {
            int prc = msg.what;
            if(prc > 0){
                ((MainActivity)res).tips.setText("Tips: "+res.getString(R.string.welcometips1));
            }
            if(prc > 30){
                ((MainActivity)res).tips.setText("Tips: "+res.getString(R.string.welcometips2));
            }
            if(prc > 60){
                ((MainActivity)res).tips.setText("Tips: "+res.getString(R.string.welcometips3));
            }
            if (prc > 100) {
                /*启动主界面
                Intent intent = new Intent();
                intent.setClass(res, MainActivity.class);
                res.startActivity(intent);*/
                if(((MainActivity)res).tr!=null){
                    ((MainActivity)res).tr.cancel();
                }
                //改变布局
                ((MainActivity)res).setContentView(R.layout.main);

                return;
            }
            ((MainActivity)res).myProgressBar.setProgress(prc);
        }
    }

然后回到我们的主界面MainActivity写上我们的初始化语句

 

  @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.welcome);
        tips=(TextView)findViewById(R.id.tips);
        myProgressBar=(ProgressBar)findViewById(R.id.loading);
        //持续滚动
        tr=new Timer();
        tr.schedule(new TimerTask(){
            @Override
            public void run() {
                MainActivity.idx++;
                process.sendEmptyMessage(MainActivity.idx);
            }
        }, 0,200);

    }

 

大功告成

运行结果如下

最后源代码在这里,仅供参考  [download id=”7″] 24.3kb

 

Written by princehaku

3月 10th, 2011 at 9:36 上午

Posted in Android

Tagged with

with one comment

大家都在android…

 

李老师,和另外个冷老师.

还有徐学长.

怎么大家都在android呢 = =

我觉得我也该弄点什么东东出来..

不然一学期的计划又没了..

Written by princehaku

3月 8th, 2011 at 10:58 下午

Posted in Android

Tagged with

with 2 comments

cdutkvb-android测试版

 

给了几个同学做测试..

效果不好..

差不多有50%的同学表示有错,日程不能进入手机

= =..

网上查了很多资料..

据说是和版本号和手机型号有关..

但是我只有G1…

还是把这个测试版的发布上来..

想用的同学就下载吧

[download id=”6″]

Written by princehaku

3月 4th, 2011 at 10:14 下午

Posted in Android

Tagged with

with 2 comments

pafetion1.2版发布

 

这个版本无需验证码

非常适合做web api

通信的说明参见这篇文档

[download id=”5″] 2.77kb 点击下载

1.3版本已经发布 点击传送

*  注意 : 请不要将此脚本用于商业用途.如果有需要,请联系移动公司

*  此脚本完全是模拟了一个浏览器让用户自主操作,不存在破解或重打包客户端等行为。

*  此脚本以学习为目的,不涉及任何商业利益。任何企业和个人与此接口有关的商业行为,请与移动公司联系。

*  任何人使用此脚本而造成的不良后果,均由使用者承担,与此脚本的作者没有任何关系。

change log:

1.修改了返回方式为xml,节点只会有action和statu,日志可以在debug开启的模式下输出

2.感谢 七子狴犴 指出的一个bug,修复了添加好友的时候姓名错误

3.感谢 追赶太阳 指出的一个bug,修复了cookie获取的代码

调用地址没有变化:

1.发送消息

http://lab.haku.hk/f/do?phone=xxxxxx&pwd=xxx&to=xxxx,xxxx,xxxx&msg=xxxx

2.添加好友

http://lab.haku.hk/f/do?phone=xxxxxx&pwd=xxx&add=xxxx,xxxx,xxxx

说明:

phone 发送者手机号码 (-v1)

pwd  发送者飞信密码 (-v1)

———————————————-

to 接收者的标志 (可以是手机号 也可以是昵称 ,昵称如果有重复的默认发第一个的)(注意:不能给自己发送) (不和v1兼容)

msg 消息的正文(默认gbk 编码) (-v1)

(可选) u 是否使用utf8编码(默认的编码是gbk , 此参数用于一些需要对中文特殊处理的地方 比如, 如果您需要做一个在线发什么东西的东西) (-v1)

———————————————-

add 需要添加成好友的手机号码

name 好友请求验证时看到的姓名

如果有问题请给我发email baizhongwei@gmail.com

 

Written by princehaku

2月 24th, 2011 at 1:01 下午

Posted in php

Tagged with , ,

with 5 comments

关于recaptcha验证码

 

image

不知道大家经常见到这种验证码不

google和很多国外的网站都有采用它

个人觉得他很复杂,要输那么多单词才行.而且模糊不可辨识.

但是实际上这个验证码大有内涵

以下是一篇来自图书上的资料

image

如果我们要把他输入到电脑里面, 常用的是ocr

就是图形文字识别技术

但是上面这个已经比较模糊了

识别出来可能会是如下的情形

‘ letz-1- rrk fit: 1’ . on its to Vc ,rt, cann into tlm yc H_ tcr,la, .n. ‘l l; , arc ti:( h of thc 1″,ats that to ltc rc: ,;. , I; ., l: rel!;n. tani., , ./olio, IJuteilu, . 1!’i./_ ;lr”n. Iiam! Jr.r. F’l,nr_.Z.._%i;;, ,, : rt-Irn: am/ tf.rri.:, t?m steamer as a tr nW r. Uu ,tin;t, c ac?1 1″,at firm/ a t;nn, accor.liu; to .t rn. ‘Cl.w r. wu ru lm:nui MistinW /y in u;th, -. ink ;:,k as to “what w ax 1111, :111(I vle:iR a of ;: (,am( into, mnr r-, tm if tlm wo r( uu.i n:’ of t?u : la?:Iv. \ ‘c : ol in thc , ucr:atic , , Tlau :; will h:aw tu-li.r \. ‘1’Im yap?tts Il ,,n an,/ I, ,rr:l. r, (,t tf,is r:ity, start witli it, with lu:rtic: ol \ 1- e:l.k.

但是如果用rechaptcha后

The New-York State yacht Squadron, on its annual cruise to Newport came into the harbor yesterday afternoon. The following are the names of the boats that came to anchor here: Jessie, gera loliv erelun Annie, Mannering, Julia, Bonita, Magic wut, Rambler, floumblie, Henrietta, Sea-Drift and Maria, with the steamer America as a tender. On anchoring each boat fired a gun, according to custom. The reports were heard distinctly in the city, causing considerable inquiry as to “what was up,” and quite a number of sanguine individuals came into our office to inquire if the guns were not annunciatory signals of the successful laying of the Atlantic Cable. We invariably replied in the negative. The squadron will leave to-day for Newport. The yachts Washington and buub r of this city, start with it, with parties of New Haven people.

对.rechaptcha .

那个验证码中 一般有两个单词或者更多 其中一个是已经知道的正确的单词

另外个随机出现的就是某个文章下影印下来的

然后当用户提交的正确单词达到一定程度的时候就标记为这个单词

当我们用这个验证码的时候也不知不觉为rechaptcha项目做了贡献.

神奇吧

更多的信息可以参考google的网站

 

Written by princehaku

2月 22nd, 2011 at 11:18 下午

Posted in technology

with 3 comments

g1入手,继续android

 

image

花了1000多,买了个G1!

权当是学习机了

刷了2.2,感觉速度还行..和模拟器差不多.

用起起来不习惯..打个字太恼火了..没5530的百度输入法安逸

现在有真机了..可以做些之前想做的东西了

之前那个s60v5的手机暂时放着.

最后运行了下上次做的校纸..很完美…

不知道我们学校用android的多不多..如果多的话

再问问徐远志.看看能不能结合下百科.就非常完美了.

Written by princehaku

2月 10th, 2011 at 5:08 下午

Posted in Android

with 6 comments

cdutkvb1.2版发布

 

理工一键一键课表入手机,今年升级了!

输入你的教务处的登录学号口令

它将自动从服务器下载课表的网页

转换成你手机的日程表存进你的手机里面

新版本可以自定义存入手机的标题格式了

kvb

支持的格式如下 :

{name}      课程名称      例:工程数学

{type}        课程类型      例:理论

{place}      上课地点      例:6A103

{score}      课程学分      例:3.5

{teacher}   上课教师      例:XXX

比如: 如果我想显示在手机上是这样的 工程数学(3)[6A103]  就输入 {name}({score})[{place}]

经测试  在诺基亚s60v5 s60v3 s40 及一些山寨,国产机上完美运行

索爱,三星的同学请暂时不要使用,存进去的时间是乱的,android等手机到的再做

除s60v5 s40外 程序在向你的手机写日程表的时候会有安全提示

按确认即可..约70次 (= =..证书太贵了..我承认有点麻烦,)

声明..本程序没有攻入,破解教务处网站.只是像浏览器一样的工作,依然需要用户登录

ps:   感谢大家的测试以及支持!!!!!

猛击下载. [download id=”4″]

Written by princehaku

2月 4th, 2011 at 2:07 下午

Posted in java,technology

Tagged with

with 12 comments

wordpress ajax 评论插件[个人汉化版]

 

首先感谢熊猫同学,..

是说怎么最近1个多月都没人留言,原来是插件改错了

现在把这个改过的插件分享给大家

这个是我汉化,优化了一下的版本

直接安装就可以了

它可以把wordpress的评论全部ajax化

带来更好的用户体验

点击下载 [download id=”3″]

Written by princehaku

1月 28th, 2011 at 5:08 下午

Posted in php

Tagged with ,

with 6 comments

上4GB了

 

s

Written by princehaku

1月 27th, 2011 at 3:18 下午

Posted in things goes by

with 4 comments

HakuVpn测试账号开始发放

 

HakuVpn现在免费提供给大家测试

请在这里输入您的邮箱

然后账号和密码都会发送到您的邮箱里面

测试的终止时间暂定为2月31号..

如果有问题请联系我哈

Written by princehaku

1月 10th, 2011 at 6:13 下午

Posted in technology

Tagged with

without comments