当前位置: 编程技术>移动开发
本页文章导读:
▪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(*******)。
创建Window ,创建的是PhoneWindow
下面是创建WindowManger
Window 被创建的时候,会执行如下代码来生成Window Attrivute
下面是更改此属性:
要更改mWindowAttributes此属性,只能用此方法,并回调。
每个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();
最新技术文章: