当前位置: 编程技术>移动开发
本页文章导读:
▪解决scrollview不滑动的有关问题 解决scrollview不滑动的问题
scrollview 使用setOnTouchListener后停止滑动:
解决办法:
一、
int touchY = 0;
private boolean isScoll ;
private void scrollView() {
behavorLayout.setOnTouchListener(new OnTouchListener() {
.........
▪ 同步跟异步 同步和异步
同步和异步的区别
举个例子:普通B/S模式(同步)AJAX技术(异步)
同步:提交请求->等待服务器处理->处理完毕返回 这个期间客户端浏览器不能干任何事
异步: 请求通.........
▪ some common usefull convertings some common usefull convertings.
Convert Drawable to bitmap:Bitmap icon= BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_resource);Convert Bitmap to drawable:Drawable d =new BitmapDrawable(bitmap);Convert i.........
[1]解决scrollview不滑动的有关问题
来源: 互联网 发布时间: 2014-02-18
解决scrollview不滑动的问题
scrollview 使用setOnTouchListener后停止滑动:
解决办法:
一、
int touchY = 0;
private boolean isScoll ;
private void scrollView() {
behavorLayout.setOnTouchListener(new OnTouchListener() {
private int lastY = 0;
private int touchEventId = -9983761;
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
View scroller = (View) msg.obj;
if (msg.what == touchEventId) {
if (lastY == scroller.getScrollY()) {
handleStop(scroller);
} else {
handler.sendMessageDelayed(handler.obtainMessage(
touchEventId, scroller), 1);
lastY = scroller.getScrollY();
}
}
}
};
@Override
public boolean onTouch(View v, MotionEvent event) {
isScoll = false;
int eventAction = event.getAction();
int y = (int) event.getRawY();
switch (eventAction) {
case MotionEvent.ACTION_UP:
if (Math.abs(touchY - y) < 20) {
} else {
handler.sendMessageDelayed(handler.obtainMessage(
touchEventId, v), 5);
}
break;
default:
break;
}
return false;
}
private void handleStop(Object view) {
this.finish(); //添加处理的代码
}
});
}
解决办法二、
public ScrollView scrollView;
private int scrollViewY;
scrollView = (ScrollView)findViewById(R.id.viewStatusDetailSV);
scrollView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
/** 滑动到顶部和底部做处理 **/
if (scrollView.getScrollY() == 0) {
Toast.makeText(context, "到达顶部了", Toast.LENGTH_SHORT).show();
} else if (scrollView.getScrollY() - scrollViewY < 2 && scrollView.getScrollY() >= scrollViewY) {
Toast.makeText(context, "到达底部了" + scrollView.getScrollY(), Toast.LENGTH_SHORT).show();
} else {
scrollViewY = scrollView.getScrollY();
}
//添加处理的代码
}
return false;
}
});
[2] 同步跟异步
来源: 互联网 发布时间: 2014-02-18
同步和异步
同步和异步的区别
举个例子:普通B/S模式(同步)AJAX技术(异步)
同步:提交请求->等待服务器处理->处理完毕返回 这个期间客户端浏览器不能干任何事
异步: 请求通过事件触发->服务器处理(这是浏览器仍然可以作其他事情)->处理完毕
--------------------------------------------
同步就是你叫我去吃饭,我听到了就和你去吃饭;如果没有听到,你就不停的叫,直到我告诉你听到了,才一起去吃饭。
异步就是你叫我,然后自己去吃饭,我得到消息后可能立即走,也可能等到下班才去吃饭。
所以,要我请你吃饭就用同步的方法,要请我吃饭就用异步的方法,这样你可以省钱。
--------------------------------------------
举个例子 打电话时同步 发消息是异步
[3] some common usefull convertings
来源: 互联网 发布时间: 2014-02-18
some common usefull convertings.
Convert Drawable to bitmap:
Convert Bitmap to drawable:
Convert imageview to bitmap:
Convert List to String[]:
Convert seconds to date time string:
Convert Drawable to bitmap:
Bitmap icon= BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_resource);Convert Bitmap to drawable:
Drawable d =new BitmapDrawable(bitmap);
Convert imageview to bitmap:
ImageView image=new ImageView(context); Bitmap viewBitmap = Bitmap.createBitmap(i.getWidth(),i.getHeight(),Bitmap.Config.ARGB_8888);//i is imageview which u want to convert in bitmap Canvas canvas = new Canvas(viewBitmap); image.draw(canvas);
Convert List to String[]:
static String[] convert(List<String[]> from) {
ArrayList<String> list = new ArrayList<String>();
for (String[] strings : from) {
Collections.addAll(list, strings);
}
return list.toArray(new String[list.size()]);
}Convert seconds to date time string:
SimpleDateFormat formatter = new SimpleDateFormat("EEEE, MMMM d, yyyy HH:mm");
String dateString = formatter.format(new Date(seconds * 1000L));
最新技术文章: