http://www.eoeandroid.com/thread-84926-1-1.html
自定义MapView类,重写其onInterceptTouchEvent方法。来实现双击以后图片变大。
java代码: - public class MyMapView extends MapView {
- private long lastTouchTime = -1;
- public MyMapView(Context context, AttributeSet attrs) {
- super(context, attrs);
- // TODO Auto-generated constructor stub
- }
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- // TODO Auto-generated method stub
- if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- long thisTime = System.currentTimeMillis();
- if (thisTime - lastTouchTime < 250) {
- this.getController().zoomInFixing((int) ev.getX(), (int) ev.getY());
- lastTouchTime = -1;
- }else{
- lastTouchTime = thisTime;
- }
- }
- return super.onInterceptTouchEvent(ev);
- }
- }
复制代码 让一个图片透明:
java代码:- Bitmap buffer = Bitmap.createBitmap(width, border="1" Height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);
复制代码 直接发送邮件:
java代码:- Intent intent = new Intent(Intent.ACTION_SENDTO, Uri .fromParts( "mailto" , "test@test.com" , null ));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
复制代码 程序控制屏幕变亮:
java代码: - WindowManager.LayoutParams lp = getWindow().getAttributes();
- lp.screenBrightness = 100 / 100 .0f;
- getWindow().setAttributes(lp);
复制代码 过滤特定文本
java代码: - Filter filter = myAdapter.getFilter();
- filter.filter(mySearchText);
复制代码 scrollView scroll停止事件
java代码: - setOnScrollListener( new OnScrollListener(){
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- // TODO Auto-generated method stub
- }
- public void onScrollStateChanged(AbsListView view, int scrollState) {
- // TODO Auto-generated method stub
- if (scrollState == 0 ) Log.i( "a" , "scrolling stopped..." );
- }
- });
- }
复制代码 对于特定的程序 发起一个关联供打开
java代码: - Bitmap bmp = getImageBitmap(jpg);
- String path = getFilesDir().getAbsolutePath() + "/test.png" ;
- File file = new File(path);
- FileOutputStream fos = new FileOutputStream(file);
- bmp.compress( CompressFormat.PNG, 100, fos );
- fos.close();
- Intent intent = new Intent();
- intent.setAction(android .content.Intent.ACTION_VIEW);
- intent.setDataAndType(Uri .fromFile( new File(path)), "image/png"
复制代码
posted on 2011-08-02 10:28
MEYE 阅读(339)
评论(0) 编辑 收藏