android 特殊用法一
1.让一个图片透明:
1. Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);
2.直接发送邮件:
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);
3.程序控制屏幕变亮:
1. WindowManager.LayoutParams lp = getWindow().getAttributes();
2. lp.screenBrightness = 100 / 100.0f;
3. getWindow().setAttributes(lp);
4.过滤特定文本
1. Filter filter = myAdapter.getFilter();
2. filter.filter(mySearchText);
5.scrollView scroll停止事件
1. setOnScrollListener(new OnScrollListener(){
2. public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
3. // TODO Auto-generated method stub }
4. public void onScrollStateChanged(AbsListView view, int scrollState) {
5. // TODO Auto-generated method stub
6. if(scrollState == 0) Log.i("a", "scrolling stopped..."); } });}
6. 对于特定的程序 发起一个关联供打开
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.
8. Intent intent = new Intent();
9. intent.setAction(android .content.Intent.ACTION_VIEW);
10. intent.setDataAndType(Uri .fromFile(new File(path)), "image/png");
11. startActivity(intent);
12. 对于图片上边的不适用索引格式会出错。
13. Intent intent = new Intent();
14. intent.setAction(android .content.Intent.ACTION_VIEW);
15. File file = new File("/sdcard/test.mp4");
16. intent.setDataAndType(Uri .fromFile(file), "video/*");
17. startActivity(intent);
18.
19. Intent intent = new Intent();
20. intent.setAction(android .content.Intent.ACTION_VIEW);
21. File file = new File("/sdcard/test.mp3");
22. intent.setDataAndType(Uri .fromFile(file), "audio/*");
23. startActivity(intent);
7.设置文本外观
1. setTextAppearance(context, android .R.style.TextAppearance_Medium);
2. android :textAppearance="?android :attr/textAppearanceMedium"
8.设置单独的发起模式:
1. <activity
2. android :name=".ArtistActivity"
3. android :label="Artist"
4. android :launchMode="singleTop">
5. </activity>
6. www.zzzyk.com
7. Intent i = new Intent();
8. i.putExtra(EXTRA_KEY_ARTIST, id);
9. i.setClass(this, ArtistActivity.class);
10. i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);&nbs
补充:移动开发 , Android ,