WEB开发网
开发学院手机开发Android 开发 Android 特殊用法介绍 阅读

Android 特殊用法介绍

 2010-05-29 05:19:00 来源:WEB开发网   
核心提示:1.让一个图片透明:Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);2.直接发送邮件:Intent intent = new Intent(I

1.让一个图片透明:

Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);

2.直接发送邮件:

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri .fromParts("mailto", "", null));

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity(intent);

3.程序控制屏幕变亮:

WindowManager.LayoutParams lp = getWindow().getAttributes();

lp.screenBrightness = 100 / 100.0f;

getWindow().setAttributes(lp);

4.过滤特定文本

Filter filter = myAdapter.getFilter();

filter.filter(mySearchText);

5.scrollView scroll停止事件

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..."); } });}

6. 对于特定的程序 发起一个关联供打开

复制到剪贴板 C/C++代码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");

startActivity(intent);

对于图片上边的不适用索引格式会出错。

Intent intent = new Intent();

intent.setAction(android .content.Intent.ACTION_VIEW);

File file = new File("/sdcard/test.mp4");

intent.setDataAndType(Uri .fromFile(file), "video/*");

1 2 3  下一页

Tags:Android 特殊 用法

编辑录入:coldstar [复制链接] [打 印]
赞助商链接