深入理解ANDROID消息处理系统——LOOPER、HANDLER、THREAD

Posted by & filed under Android, Java.

(自) Activity,Service属于主线程,在主线程中才能更新UI,如toast等。其他线程中不能直接使用,这时可以使用Handler来处理,Handler可以在Activity和Service中。

关于在非UI线程中进行UI操作会出现问题: Can’t create handler inside thread that has not called Looper.prepare()

这时有两种方式来解决:

(一)在该非UI线程中创建消息队列(因为创建的工作线程默认是没有消息循环和消息队列的),Looper.prepare();…..;Looper.loop(); 

 newThread() { 

public void run() {

 Looper.prepare(); //创建消息队列

 todo(); 

 Looper.loop();//进入消息循环

}}.start();

(二)运用Handler机制:

package com.simon;

import android.app.Activity; 
import android.os.Bundle; 
import android.os.Message; 
import android.util.Log; …

Java Tip 10: Implement callback routines in Java

Posted by & filed under Java.

This story appeared on JavaWorld at

http://www.javaworld.com/javatips/jw-javatip10.html

Java Tip 10: Implement callback routines in Java

Using interfaces to implement the equivalent<BR> of callback functions in Java

Developers conversant in the event-driven programming model of MS-Windows and the

Cursors in SQL

Posted by & filed under DATABASE, ORACLE, SQLSERVER.

SQL was designed as a set-oriented processing language. Some business rules( or poor physical design) require performing actions on row-by-row basis. Consider the following example:
. Increase the price of books <=$15 by 15%
. Decrease the price of books …

Basic Rules of Normalization

Posted by & filed under DATABASE, ORACLE, SQLSERVER.

Without going into a dissertation on data modeling(itself a subject of many full-length treatises), tables should follow basic rules of normalization:

Avoid duplicate data, avoid repeating groups in tables, and only put data in tables where the information is directly

The logical processing of the Select statement

Posted by & filed under SQLSERVER.

CREATE TABLE Loans (
 loan_nbr INT NOT NULL ,
 customer_nbr INT NOT NULL,
 loan_date DATETIME NOT NULL,�
 loan_amount DECIMAL(15, 2) NOT NULL,
 loan_type CHAR(1) NOT NULL,
 CONSTRAINT ck_loan_type
 CHECK (loan_type IN(‘P’,’B’)), — P = Personal; –B=Business
 CONSTRAINT pk_loans
 PRIMARY KEY(loan_nbr));…

SQL Server中行列转换 Pivot UnPivot

Posted by & filed under SQLSERVER.

PIVOT用于将列值旋转为列名(即行转列),在SQL Server 2000可以用聚合函数配合CASE语句实现

PIVOT的一般语法是:PIVOT(聚合函数(列) FOR 列 in (…) )AS P

完整语法:

table_source

PIVOT(

聚合函数(value_column)

FOR pivot_column

IN(<column_list>)

)

 

UNPIVOT用于将列明转为列值(即列转行),在SQL Server 2000可以用UNION来实现

完整语法:

table_source

UNPIVOT(

value_column

FOR pivot_column

IN(<column_list>)

)

 

注意:PIVOT、UNPIVOT是SQL Server 2005 的语法,使用需修改数据库兼容级别
 在数据库属性->选项->兼容级别改为   90

 

典型实例

一、行转列

旧版本的Crystal Reports升级到Crystal Reports forVisual Studio 2010时的错误解决方法

Posted by & filed under Visual Studio.

我在使用BOOK: Professional Crystal Reports for VS.NET 的时候,经常出错:
…..Assembles不能用。。。。

这里最好的解决办法是,1.重新安装.Net FrameWork,2. Select the Compile tab and click on the “Advanced Compile Options…” button. Find “Target CPU” and set it to x86. Next find “Target Framework” and set it to .NET Framework …

固定宽度下拉列表中option内容显示不全问题解决方法

Posted by & filed under JavaScript.

不少时候在页面中为了布局的需要,下拉列表<select>的宽度需要设成比较小的值,这时如果恰巧它包含的选择项<option>的内容比较长,那么超出select宽度的部分将会被截断,如果option显示的内容又比较重要,必须完整地展现出来,或者你是个完美主义者,那这就成了一个不大不小的问题了。

在IE7+、Firefox中,由于支持了<option>的title属性,我们可以想办法给option标记设置title属性(内容可以与显示的值相同或者不同)。如果是已经做好的页面,不想再做太多改动,可以用下面的脚本,自动遍历页面上的所有<select>,给所有的option加上与text相同的title。

function SetOptionTitle()
{
    var selects = document.getElementsByTagName(“select”);
    if (selects.length > 0)
    {
        for (var i = 0; i < selects.length; i++)
        {
            var options = selects[i].options;
            if (selects[i].options.length > 0)
            {
                for (var j = 0; j < 

APK文件反编译 查看源代码 相关工具下载

Posted by & filed under Android.

反编译APK文件需要dex2jar和jd-gui这两个工具,我已经打包了,可以本文底部下载。
第一步、下载我提供的工具后解压。
第二步、把目标APK文件扩展名改为zip,用WINRAR或者其他压缩软件打开,解压其中的classes.dex,并放到上面第一步解压出来的工具目录里
如图:

第三步、双击执行目录中的First.bat,会在当前目录生成一个classes.dex.dex2jar.jar文件
第四步、打开jd-gui.exe,File-Open File找到刚才生成的classes.dex.dex2jar.jar文件
OK,现在你可以看到Java源代码了.
如果需要查看APK中的XML文件以及图片,可以用apktool,这里也一并附上,已经放进压缩包里了,上面的截图没有,使用方法:

apktool.bat d apk名 解压目录

工具下载:
apkdecode (35)

or ApkDecode

From:http://www.pocketdigi.com/20110905/459.html