当前位置: 编程技术>移动开发
本页文章导读:
▪TableRow数据更新时加下高亮背景 TableRow数据更新时加上高亮背景
一般Table的数据(行)更新时,要配合一定的动画效果,才能引起用户注意。 在Android里,颜色值用8位的16进制来表示,其中前两2位用来表示 alpha channel,.........
▪ IPone低级开发的小技巧 IPone初级开发的小技巧
1.点击F9回到桌面,并且显示所有打开的程序。
2.点击F11回桌面。
3.NSUInteger表示无符号整形数。
4.选中多行代码,按开始+"/"注释多行代码。
5.在Xcode中将外部文件拖入到.........
▪ 设立桌面快捷方式 设置桌面快捷方式
如何在程序中设置桌面快捷方式(home screen shortcut):
/**
*创建桌面图标(Home Screen Shortcut)
*
* @param context the context
* @param clz 快捷方式启动的Activity
*/
public static void mak.........
[1]TableRow数据更新时加下高亮背景
来源: 互联网 发布时间: 2014-02-18
TableRow数据更新时加上高亮背景
一般Table的数据(行)更新时,要配合一定的动画效果,才能引起用户注意。
在Android里,颜色值用8位的16进制来表示,其中前两2位用来表示 alpha channel, 后6位用来表示rgb. 在程序里面,只要在指定时间内,将alpha channel从 0调整到 0xff,就实现了 highlight TableRow.
一般Table的数据(行)更新时,要配合一定的动画效果,才能引起用户注意。
在Android里,颜色值用8位的16进制来表示,其中前两2位用来表示 alpha channel, 后6位用来表示rgb. 在程序里面,只要在指定时间内,将alpha channel从 0调整到 0xff,就实现了 highlight TableRow.
- 下面是用线程来实现:
class ColorRefreshTask extends TimerTask {
final static int DELAY_ONCE =200;
final static int TOTAL_RUNTIME = 3000;
final static int POWER_16_16 = 16 * 16* 16 * 16 * 16 * 16;
final static int INCREASE_ONCE = 0xff / (TOTAL_RUNTIME / DELAY_ONCE);
int color;
int id;
int startTime;
int alphaChannel;
/**
*
* @param color (TableRow's current background color)
* @param id TableRow's id(user id)
*/
public ColorRefreshTask(int color, int id) {
super();
Log.d("color", "ready to set color!");
this.color = color;
this.id = id;
this.startTime = 0;
this.alphaChannel = 0;
}
public void run(){
int colorComm = color -0xff000000; //RGB color value;
int currColor = color;
if(startTime < TOTAL_RUNTIME) {
startTime += DELAY_ONCE;
alphaChannel += INCREASE_ONCE;
currColor = POWER_16_16 * alphaChannel + colorComm;
Log.d("color", Integer.toHexString(currColor));
sendMsg(currColor);
messageHandler.postDelayed(this,DELAY_ONCE);
}
else {
sendMsg(currColor);
}
}
public void startTimer(){
messageHandler.postDelayed(this,DELAY_ONCE);
}
private void sendMsg(int currColor){
Message message = messageHandler.obtainMessage();
message.what = MESSAGE_HANDLE_ID_UPDATEROW_BACKGROUND;
Bundle bundle = new Bundle();
bundle.putInt(MESSAGE_KEY_ID, id);
bundle.putInt(MESSAGE_KEY_COLOR, currColor);
message.setData(bundle);
messageHandler.sendMessage(message);
}
public void stopTimer(){
this.cancel();
}
}- 消息处理部分:
private static final int MESSAGE_HANDLE_ID = 800;
private static final int MESSAGE_HANDLE_ID_UPDATEROW_DATA = MESSAGE_HANDLE_ID + 1;
private static final int MESSAGE_HANDLE_ID_UPDATEROW_BACKGROUND = MESSAGE_HANDLE_ID +2;
private Handler messageHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case MESSAGE_HANDLE_ID_UPDATEROW_DATA:{
int id = msg.getData().getInt(MESSAGE_KEY_ID);
String fields[] = new String[5];
fields[0] = msg.getData().getString("fields1");
fields[1] = msg.getData().getString("fields2");
fields[2] = msg.getData().getString("fields3");
fields[3] = msg.getData().getString("fields4");
fields[4] = msg.getData().getString("fields5");
updateRowInTable(id, fields);
break;
}
case MESSAGE_HANDLE_ID_UPDATEROW_BACKGROUND:
{
int id = msg.getData().getInt(MESSAGE_KEY_ID);
int color = msg.getData().getInt(MESSAGE_KEY_COLOR);
TableRow tableRow= (TableRow)findViewById( id);
if(tableRow != null) {
int count = tableRow.getChildCount();
for(int index = 0; index < count; index++) {
TextView child = (TextView)(tableRow.getChildAt(index));
if(child != null) {
child.setBackgroundColor(color);
}
}
}
break;
}
default:
}
}
};
- 数据更新(其他线程会调用)部分:
private final void updateRowInTable(int code,String[] otherFields) {
TableRow tableRow= (TableRow)findViewById(code);
if(tableRow == null) {
Log.d("tablerow", "can't find row in the table!");
return;
}
int bgColorEnd = (otherFields[2].indexOf("-") >= 0) ? 0xff2e8b57 : 0xffb22222;
for(int index = 0; index < otherFields.length; index++) {
int identity = code * 13 +(index+1);
TextView textView= (findViewById(identity)!= null) ? (TextView) findViewById(identity) : new TextView(this);
if(otherFields[index].indexOf('-') >=0) {
textView.setTextColor(Color.GREEN);
}
else if( index == 2) {
textView.setTextColor(Color.RED);
}
else {
textView.setTextColor(Color.WHITE);
}
textView.setText(otherFields[index]);
Log.d("tablerow", "updated id:" + (code) + ", value=" + otherFields[index] );
if(findViewById(identity) == null){
textView.setId(identity);
tableRow.addView(textView);
Log.d("tablerow", "add new view!");
}
else {
Log.d("tablerow", "upate view!");
}
textView.postInvalidate();
//textView.invalidate();
}
tableRow.postInvalidate();
//tableRow.invalidate();
ColorRefreshTask refresh = new ColorRefreshTask(bgColorEnd,code);
messageHandler.postDelayed(refresh, 50);
}
[2] IPone低级开发的小技巧
来源: 互联网 发布时间: 2014-02-18
IPone初级开发的小技巧
1.点击F9回到桌面,并且显示所有打开的程序。
2.点击F11回桌面。
3.NSUInteger表示无符号整形数。
4.选中多行代码,按开始+"/"注释多行代码。
5.在Xcode中将外部文件拖入到工程中时,并没有将外部文件复制到本工程,在将外
部文件删除后,此工程就找不到拖入的外部文件了。要解决此问题,可现将外部文件
复 制到本工程,然后再拖入到Xcode的工程中。
6.再Xcode中点击shift+开始(windows 键盘) +F进行查找,在查找时在find后的下拉
框 中要选择 in project,在replace后的下拉框中选择Textual。
[3] 设立桌面快捷方式
来源: 互联网 发布时间: 2014-02-18
设置桌面快捷方式
如何在程序中设置桌面快捷方式(home screen shortcut):
/**
*创建桌面图标(Home Screen Shortcut)
*
* @param context the context
* @param clz 快捷方式启动的Activity
*/
public static void makeShortcut(Context context,Class<?> clz) {
Intent shortcutIntent = new Intent(context,clz);
// shortcutIntent.setClassName(packageName, name);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, context.getResources().getString(R.string.app_name));
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.icon) );
intent.setAction(Intent.ACTION_CREATE_SHORTCUT);
context.sendBroadcast(intent);
}
设置快捷方式的目标Activity 该Activity一般具有如下的设置:
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
1 楼
1927105
2010-08-16
不行啊,我专门写一个工具类也不行啊,,,
2 楼
hyfeng0523
2010-09-08
楼主的方法可行,如果我想要某一个Activity放在桌面快捷方式呢?这个Activity没有MAIN属性与LAUNCHER属性/?如何实现?
最新技术文章: