当前位置: 编程技术>移动开发
本页文章导读:
▪UILabel 展示 换行 UILabel 显示 换行
UILabel*label;//设置换行label.lineBreakMode = UILineBreakModeWordWrap; label.numberOfLines = 0;换行符还是\n比如NSString * xstring=@"lineone\nlinetwo"记得要把label的高度设置的足够显示多行内容。
......
▪ 用署理模式处理海量高频数据更新 用代理模式处理海量高频数据更新
业务背景: 海量高频数据(如股票实时报价), 更新的规则: 被更新的对象和更新方法都不一样.下面是部分实例代码,最后一个是模拟的数据更新。public inter.........
▪ Milestone 改换系统字体 Milestone 更换系统字体
前提:我刷成了MIUI,使用的是“Plus 工具箱”,更换字体和启动动画都在工具箱的“显示/控制设置”里面。(原生的Android也可以使用ITFUNZ出品的“超级工具箱”设置,.........
[1]UILabel 展示 换行
来源: 互联网 发布时间: 2014-02-18
UILabel 显示 换行
UILabel*label;
//设置换行
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 0;
换行符还是\n
比如NSString * xstring=@"lineone\nlinetwo"
记得要把label的高度设置的足够显示多行内容。
UILabel*label;
//设置换行
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 0;
换行符还是\n
比如NSString * xstring=@"lineone\nlinetwo"
记得要把label的高度设置的足够显示多行内容。
[2] 用署理模式处理海量高频数据更新
来源: 互联网 发布时间: 2014-02-18
用代理模式处理海量高频数据更新
业务背景: 海量高频数据(如股票实时报价), 更新的规则: 被更新的对象和更新方法都不一样.
下面是部分实例代码,最后一个是模拟的数据更新。
这也也打包了,需要的可以看一下。
业务背景: 海量高频数据(如股票实时报价), 更新的规则: 被更新的对象和更新方法都不一样.
下面是部分实例代码,最后一个是模拟的数据更新。
public interface CommonDefn {
public static int HIGHLIGHT_BACKGROUND_COLOR_INDEX = 0xff0033ff;
public class DoThingsReturn{
public Object cmd;
public Object data;
public int errCode;
public DoThingsReturn(Object cmd, Object data, int errorCode) {
super();
this.cmd = cmd;
this.data = data;
this.errCode = errorCode;
}
}
}
/**
* used for updating the background of the view while the data changed
*
*
*/
public interface RefreshHandlerInterface {
public void updateBackground(Object handlerId, int color); //the proxy updating method
public Handler getHandler(); //the proxy handler
}
/**
*
* decrease alpha channel value from 255 to 0.
*
*/
public class ColorRefreshTask extends TimerTask {
private RefreshHandlerInterface refreshHandler;
private final static int DELAY_ONCE =200;
private final static int TOTAL_RUNTIME = 1500;
private final static int POWER_16_16 = 16 * 16* 16 * 16 * 16 * 16;
private final static int INCREASE_ONCE = 0xff / (TOTAL_RUNTIME / DELAY_ONCE);
private int color;
private Object id;
private int startTime;
private int alphaChannel;
/**
*
* @param color ( current background color)
* @param id id of the updated view
*/
public ColorRefreshTask(RefreshHandlerInterface refreshHandler, int color, Object id) {
super();
Log.d("color", "ready to set color!");
this.color = color;
this.id = id;
this.startTime = 0;
this.alphaChannel = 0;
this.refreshHandler = refreshHandler;
}
public void run(){
int colorComm = color - 0xff000000; //RGB color value;
int currColor = 0;
if(startTime < TOTAL_RUNTIME) {
startTime += DELAY_ONCE;
alphaChannel += INCREASE_ONCE;
currColor = POWER_16_16 * alphaChannel + colorComm;
//Log.d("color", Integer.toHexString(currColor));
sendMsg(currColor);
refreshHandler.getHandler().postDelayed(this,DELAY_ONCE);
}
else {
sendMsg(currColor <= color ? color : 0 );
cancel();
}
}
public void startTimer(){
refreshHandler.getHandler().postDelayed(this,DELAY_ONCE);
}
private void sendMsg(final int currColor){
final Runnable myUpdateResults = new Runnable() {
public void run() {
refreshHandler.updateBackground( id, currColor);
}
};
new Thread() {
public void run() {
refreshHandler.getHandler().post(myUpdateResults);
}
}.start();
}
public void stopTimer(){
this.cancel();
}
}
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;
public class TestActivity extends Activity implements RefreshHandlerInterface{
private Handler _messageHandler = new Handler();
@Override
public Handler getHandler() {
return _messageHandler;
}
@Override
public void updateBackground(Object handlerId, int color) {
if(!( handlerId instanceof CommonDefn.DoThingsReturn)) {
return; //invalid parameter
}
else {
TextView current = (TextView)(((CommonDefn.DoThingsReturn)handlerId).data);
if(current.getVisibility() != View.VISIBLE) {
return; //no need to update for the view
}
if(color<=0) {
current.setBackgroundDrawable(null);
current.setText(((CommonDefn.DoThingsReturn)handlerId).cmd.toString());
}
else {
current.setBackgroundColor( color);
}
current.postInvalidate();
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView tv = (TextView)findViewById(R.id.txtview);
new Thread() {
java.util.Random rand = new java.util.Random();
long lastUpdate = System.currentTimeMillis();
public void run() {
while(!Thread.interrupted() || !TestActivity.this.isFinishing()) {
//模拟高频更新数据
if( System.currentTimeMillis() - lastUpdate < 2000l) { //设置两次动画的最少间隔时间
continue;
}
else
lastUpdate = System.currentTimeMillis();
CommonDefn.DoThingsReturn updateWrapper = new CommonDefn.DoThingsReturn(String.valueOf(rand.nextInt()) , tv,0);
ColorRefreshTask refresh = new ColorRefreshTask(TestActivity.this,CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX, updateWrapper);
_messageHandler.postDelayed(refresh, 200); //ready to for the current updating
}
}
}.start();
}
}这也也打包了,需要的可以看一下。
1 楼
sungod
2010-12-03
谢谢了,下来看看注释再多点就完美了。
2 楼
Coding.Ghost
2010-12-12
好吧.我承认.我看不太懂..
[3] Milestone 改换系统字体
来源: 互联网 发布时间: 2014-02-18
Milestone 更换系统字体
前提:我刷成了MIUI,使用的是“Plus 工具箱”,更换字体和启动动画都在工具箱的“显示/控制设置”里面。(原生的Android也可以使用ITFUNZ出品的“超级工具箱”设置,操作方法类似)
这个很简单,先下载所需要的字体压缩包,解压后放到SD卡的任意位置(你应该能记住,比如我就放在:/sdcard/EwinLive/fonts)。可以放置多个字体文件夹,最好不要包含中文。
打开“Plus 工具箱” -> “显示/控制设置”->"系统字体更换",按菜单键,选择“更改字体目录”,输入您放置字体文件夹的目录(比如:/sdcard/EwinLive/fonts)
您可以先预览一下字体,点击“更换字体”,重启手机就OK了。
附送系统字体:
(deafult.rar是系统默认字体)
最新技术文章: