当前位置:  编程技术>移动开发
本页文章导读:
    ▪java list 汉语排序        java list 中文排序 import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; public class ChineseCharacterSortDemo { public static void ma.........
    ▪ Activity起动        Activity启动 每个Activity的创建,都会执行到ActivityThread类中的Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) 此类负责创建Activity实例和一些information。并回调一些Activity 的回调函.........
    ▪ 从图片字节中取得高和宽       从图片字节中获得高和宽 将图片以字节的形式储存在数组中后 获得其高和款的方法 Got the answer from http://apachejava.blogspot.com/2011/01/get-width-and-height-of-image-blob.html public Bitmap convertBlobToBitmap(byte.........

[1]java list 汉语排序
    来源: 互联网  发布时间: 2014-02-18
java list 中文排序
import java.text.Collator;   
import java.util.ArrayList;   
import java.util.Collections;   
import java.util.Comparator;   
import java.util.Iterator;   
  
public class ChineseCharacterSortDemo {   
    public static void main(String args[]) {   
        ArrayList list = new ArrayList();   
        list.add(new Country(86, "中国"));   
        list.add(new Country(21, "加拿大"));   
        list.add(new Country(1, "美国"));   
        list.add(new Country(110, "阿富汗"));   
        Comparator cmp = new ChinsesCharComp();   
        Collections.sort(list, cmp);   
        Iterator iter = list.iterator();   
        while (iter.hasNext()) {   
            Country s1 = (Country) iter.next();   
            System.out.println(s1.getCode() + "----" + s1.getName());   
        }   
    }   
}   
  
class ChinsesCharComp implements Comparator {   
  
    public int compare(Object o1, Object o2) {   
        Country c1 = (Country) o1;   
        Country c2 = (Country) o2;   
        Collator myCollator = Collator.getInstance(java.util.Locale.CHINA);   
        if (myCollator.compare(c1.getName(), c2.getName()) < 0)   
            return -1;   
        else if (myCollator.compare(c1.getName(), c2.getName()) > 0)   
            return 1;   
        else  
            return 0;   
    }   
}   
  
class Country {   
  
    private long code;   
  
    private String name;   
  
    public long getCode() {   
        return code;   
    }   
  
    public void setCode(long code) {   
        this.code = code;   
    }   
  
    public String getName() {   
        return name;   
    }   
  
    public void setName(String name) {   
        this.name = name;   
    }   
  
    public Country() {   
  
    }   
  
    public Country(long code, String name) {   
        this.code = code;   
        this.name = name;   
    }   
  
}

    
[2] Activity起动
    来源: 互联网  发布时间: 2014-02-18
Activity启动
每个Activity的创建,都会执行到ActivityThread类中的
Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) 此类负责创建Activity实例和一些information。并回调一些Activity 的回调函数 onXXX().

其中调用了 activity.attach(*******)。
    final void attach(Context context, ActivityThread aThread,
            Instrumentation instr, IBinder token, int ident,
            Application application, Intent intent, ActivityInfo info,
            CharSequence title, Activity parent, String id,
            Object lastNonConfigurationInstance,
            HashMap<String,Object> lastNonConfigurationChildInstances,
            Configuration config) {
        attachBaseContext(context);

        mWindow = PolicyManager.makeNewWindow(this);
        mWindow.setCallback(this);
        if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
            mWindow.setSoftInputMode(info.softInputMode);
        }
        mUiThread = Thread.currentThread();

        mMainThread = aThread;
        mInstrumentation = instr;
        mToken = token;
        mIdent = ident;
        mApplication = application;
        mIntent = intent;
        mComponent = intent.getComponent();
        mActivityInfo = info;
        mTitle = title;
        mParent = parent;
        mEmbeddedID = id;
        mLastNonConfigurationInstance = lastNonConfigurationInstance;
        mLastNonConfigurationChildInstances = lastNonConfigurationChildInstances;

        mWindow.setWindowManager(null, mToken, mComponent.flattenToString());
        if (mParent != null) {
            mWindow.setContainer(mParent.getWindow());
        }
        mWindowManager = mWindow.getWindowManager();
        mCurrentConfig = config;
    }


创建Window ,创建的是PhoneWindow
private static final String POLICY_IMPL_CLASS_NAME =
        "com.android.internal.policy.impl.Policy";

    static {
        // Pull in the actual implementation of the policy at run-time
        try {
            Class policyClass = Class.forName(POLICY_IMPL_CLASS_NAME);
            sPolicy = (IPolicy)policyClass.newInstance();
        } catch (ClassNotFoundException ex) {
            throw new RuntimeException(
                    POLICY_IMPL_CLASS_NAME + " could not be loaded", ex);
        } catch (InstantiationException ex) {
            throw new RuntimeException(
                    POLICY_IMPL_CLASS_NAME + " could not be instantiated", ex);
        } catch (IllegalAccessException ex) {
            throw new RuntimeException(
                    POLICY_IMPL_CLASS_NAME + " could not be instantiated", ex);
        }
    }
上面代码是静态模块,类被加载时就被执行。
    public static Window makeNewWindow(Context context) {
        return sPolicy.makeNewWindow(context);
    }
    public PhoneWindow makeNewWindow(Context context) {
        return new PhoneWindow(context);
    }

下面是创建WindowManger
mWindow.setWindowManager(null, mToken, mComponent.flattenToString());
    public void setWindowManager(WindowManager wm,
            IBinder appToken, String appName) {
        mAppToken = appToken;
        mAppName = appName;
        if (wm == null) {
            wm = WindowManagerImpl.getDefault();
        }
        mWindowManager = new LocalWindowManager(wm);
    }
wm = WindowManagerImpl.getDefault();是返回一个默认的WindowManagerImpl 的静态实例,在android系统中的所有应用程序,都共用一个WindowManagerImpl实例。

Window 被创建的时候,会执行如下代码来生成Window  Attrivute
    private final WindowManager.LayoutParams mWindowAttributes =
        new WindowManager.LayoutParams();

下面是更改此属性:
    /**
     * Specify custom window attributes.  <strong>PLEASE NOTE:</strong> the
     * layout params you give here should generally be from values previously
     * retrieved with {@link #getAttributes()}; you probably do not want to
     * blindly create and apply your own, since this will blow away any values
     * set by the framework that you are not interested in.
     *
     * @param a The new window attributes, which will completely override any
     *          current values.
     */
    public void setAttributes(WindowManager.LayoutParams a) {
        mWindowAttributes.copyFrom(a);
        if (mCallback != null) {
            mCallback.onWindowAttributesChanged(mWindowAttributes);
        }
    }

要更改mWindowAttributes此属性,只能用此方法,并回调。

    
[3] 从图片字节中取得高和宽
    来源: 互联网  发布时间: 2014-02-18
从图片字节中获得高和宽

将图片以字节的形式储存在数组中后 获得其高和款的方法

Got the answer from

http://apachejava.blogspot.com/2011/01/get-width-and-height-of-image-blob.html

public Bitmap convertBlobToBitmap(byte[] blobByteArray) {       
        Bitmap tempBitmap=null;        
        if(blobByteArray!=null)
        tempBitmap = BitmapFactory.decodeByteArray(blobByteArray, 0, blobByteArray.length);

        return tempBitmap;
    }


Bitmap temp_bitmapImg = convertBlobToBitmap(BitmapArrayOfImage());
                int height = temp_bitmapImg .getHeight();
                int width = temp_bitmapImg .getWidth();


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
oracle iis7站长之家
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3