posts - 189,comments - 115,trackbacks - 0

          Android 一些小效果代碼

          http://www.eoeandroid.com/thread-84926-1-1.html
          自定義MapView類,重寫其onInterceptTouchEvent方法。來實現雙擊以后圖片變大。

          java代碼:
          1. public class MyMapView extends MapView {

          2. private long lastTouchTime = -1;
          3. public MyMapView(Context context, AttributeSet attrs) {
          4. super(context, attrs);
          5. // TODO Auto-generated constructor stub

          6. }

          7. @Override
          8. public boolean onInterceptTouchEvent(MotionEvent ev) {
          9. // TODO Auto-generated method stub
          10. if (ev.getAction() == MotionEvent.ACTION_DOWN) {

          11. long thisTime = System.currentTimeMillis();

          12. if (thisTime - lastTouchTime < 250) {

          13. this.getController().zoomInFixing((int) ev.getX(), (int) ev.getY());
          14. lastTouchTime = -1;

          15. }else{
          16. lastTouchTime = thisTime;

          17. }
          18. }

          19. return super.onInterceptTouchEvent(ev);
          20. }
          21. }
          復制代碼

                 讓一個圖片透明:

          java代碼:
          1. Bitmap buffer = Bitmap.createBitmap(width, border="1" Height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);
          復制代碼

                 直接發送郵件:

          java代碼:
          1. Intent intent = new Intent(Intent.ACTION_SENDTO, Uri .fromParts( "mailto" , "test@test.com" , null ));

          2. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          3. context.startActivity(intent);
          復制代碼

                 程序控制屏幕變亮:

          java代碼:
          1. WindowManager.LayoutParams lp = getWindow().getAttributes();
          2. lp.screenBrightness = 100 / 100 .0f;
          3. getWindow().setAttributes(lp);
          復制代碼

                  過濾特定文本

          java代碼:
          1. Filter filter = myAdapter.getFilter();
          2. filter.filter(mySearchText);
          復制代碼

                 scrollView scroll停止事件

          java代碼:
          1. setOnScrollListener( new OnScrollListener(){

          2. public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
          3. // TODO Auto-generated method stub
          4. }

          5. public void onScrollStateChanged(AbsListView view, int scrollState) {
          6. // TODO Auto-generated method stub

          7. if (scrollState == 0 ) Log.i( "a" , "scrolling stopped..." );
          8. }

          9. });
          10. }
          復制代碼

                 對于特定的程序 發起一個關聯供打開

          java代碼:
          1. Bitmap bmp = getImageBitmap(jpg);
          2. String path = getFilesDir().getAbsolutePath() + "/test.png" ;
          3. File file = new File(path);
          4. FileOutputStream fos = new FileOutputStream(file);
          5. bmp.compress( CompressFormat.PNG, 100, fos );
          6. fos.close();

          7. Intent intent = new Intent();
          8. intent.setAction(android .content.Intent.ACTION_VIEW);
          9. intent.setDataAndType(Uri .fromFile( new File(path)), "image/png"
          復制代碼
          posted on 2011-08-02 10:28 MEYE 閱讀(345) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 扎赉特旗| 海盐县| 浑源县| 衡东县| 加查县| 修武县| 土默特右旗| 三河市| 琼中| 太仓市| 盐山县| 射洪县| 顺昌县| 龙井市| 额济纳旗| 乌鲁木齐市| 如东县| 邵东县| 高邮市| 阳山县| 磐安县| 清远市| 威宁| 娄烦县| 九江县| 汝阳县| 兰州市| 锡林郭勒盟| 邹城市| 沂南县| 商洛市| 宕昌县| 屯留县| 常熟市| 呼玛县| 榆林市| 德庆县| 双城市| 年辖:市辖区| 丹江口市| 兴山县|