当前位置:  编程技术>移动开发
本页文章导读:
    ▪调用系统的传媒音量控制显示        调用系统的媒体音量控制显示 调大声:1 AudioManager audioMa=(AudioManager)this.getSystemService(Context.AUDIO_SERVICE);2 audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,AudioManager.ADJUST_RAISE,AudioManager.FX_FOCUS_NAVIGATION_UP).........
    ▪ 在view左下角原点处绘制Button        在view左上角原点处绘制Button 载:http://nachbaur.com/blog/building-a-custom-dashboard-uibutton  As part of the Parking Mobility iPhone app I’ve been building, I wanted to integrate a simple “Quick Start” help guide to show people how t.........
    ▪ Bookmark的取得       Bookmark的获得  setContentView(R.layout.main);  TextView tv = (TextView) findViewById(R.id.hello);  String[] projection = new String[] { Browser.BookmarkColumns.TITLE,    Browser.BookmarkColumns.URL };  Cursor mCur = managedQuery(android.........

[1]调用系统的传媒音量控制显示
    来源: 互联网  发布时间: 2014-02-18
调用系统的媒体音量控制显示


调大声:

1 AudioManager audioMa=(AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
2 audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,AudioManager.ADJUST_RAISE,
AudioManager.FX_FOCUS_NAVIGATION_UP);

调小声:

1 AudioManager audioMa=(AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
2 audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,AudioManager.ADJUST_LOWER,
AudioManager.FX_FOCUS_NAVIGATION_UP);


    
[2] 在view左下角原点处绘制Button
    来源: 互联网  发布时间: 2014-02-18
在view左上角原点处绘制Button

载:http://nachbaur.com/blog/building-a-custom-dashboard-uibutton



 
As part of the Parking Mobility iPhone app I’ve been building, I wanted to integrate a simple “Quick Start” help guide to show people how to use the app without being intrusive.  I wanted to use the project’s branding as much as possible, and give the user a feeling like they haven’t left the main portion of the app.  So I wanted the user to be comfortable with it, and always have a quick way to close the help window to get back to the app.


The end result is actually really simple.  I subclassed the UIButton class, and overrode the drawRect: method to use some native drawing primitives.

//
//  DNCloseButton.h
//  ParkingMobility
//
//  Created by Michael Nachbaur on 10-08-22.
//  Copyright 2010 Decaf Ninja Software. All rights reserved.
//

#import 
#import 

@interface DNCloseButton : UIButton {
}

@end


//

//  DNCloseButton.m
//  ParkingMobility
//
//  Created by Michael Nachbaur on 10-08-22.
//  Copyright 2010 Decaf Ninja Software. All rights reserved.
//

#import "DNCloseButton.h"

@implementation DNCloseButton

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
CGFloat radius = self.bounds.size.width / 2;
CGFloat borderWidth = self.bounds.size.width / 10;

self.layer.backgroundColor = [[UIColor blackColor] CGColor];
self.layer.borderColor = [[UIColor whiteColor] CGColor];
self.layer.borderWidth = borderWidth;
self.layer.cornerRadius = radius;

if ([self.layer respondsToSelector:@selector(setShadowOffset:)])
self.layer.shadowOffset = CGSizeMake(0.25, 0.25);

if ([self.layer respondsToSelector:@selector(setShadowColor:)])
self.layer.shadowColor = [[UIColor blackColor] CGColor];

if ([self.layer respondsToSelector:@selector(setShadowRadius:)])
self.layer.shadowRadius = borderWidth;

if ([self.layer respondsToSelector:@selector(setShadowOpacity:)])
self.layer.shadowOpacity = 0.75;

[self setNeedsDisplay];
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(ctx, true);

CGFloat xsize = self.bounds.size.width / 6;
CGFloat borderWidth = self.bounds.size.width / 10;

CGContextSaveGState(ctx);

CGContextSetLineCap(ctx, kCGLineCapRound);
CGContextSetLineWidth(ctx, borderWidth);
CGContextSetStrokeColorWithColor(ctx, [[UIColor whiteColor] CGColor]);

CGFloat width = self.bounds.size.width;
CGPoint start1 = CGPointMake(width / 2 - xsize, width / 2 - xsize);
CGPoint end1 = CGPointMake(width / 2 + xsize, width / 2 + xsize);
CGPoint start2 = CGPointMake(width / 2 + xsize, width / 2 - xsize);
CGPoint end2 = CGPointMake(width / 2 - xsize, width / 2 + xsize);

CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, start1.x, start1.y);
CGContextAddLineToPoint(ctx, end1.x, end1.y);
CGContextStrokePath(ctx);

CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, start2.x, start2.y);
CGContextAddLineToPoint(ctx, end2.x, end2.y);
CGContextStrokePath(ctx);

CGContextRestoreGState(ctx);
}

@end
 

Reading through the source code, you can see how I split the drawing between two different routines.  First, my layer drawing which draws the border, the circle, shadows, etc is handled using raw CALayer drawing.  The second block, inside drawRect:, draws the lines forming the “X” inside.



CGFloat closeSize = 26.0;
CGRect butframe = CGRectMake(0.0, 0.0, closeSize, closeSize);
butframe.origin.x = contentView.frame.origin.x - closeSize / 2;
butframe.origin.y = contentView.frame.origin.y - closeSize / 2;

DNCloseButton *button = [[[DNCloseButton alloc] initWithFrame:butframe] autorelease];
[button addTarget:self action:@selector(closePopup:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:button];
 

If you find any bugs in this code, please let me know and I’ll update this post.  I hope this works out as well for you as it has for me.

 


    
[3] Bookmark的取得
    来源: 互联网  发布时间: 2014-02-18
Bookmark的获得

 setContentView(R.layout.main);
  TextView tv = (TextView) findViewById(R.id.hello);
  String[] projection = new String[] { Browser.BookmarkColumns.TITLE,
    Browser.BookmarkColumns.URL };
  Cursor mCur = managedQuery(android.provider.Browser.BOOKMARKS_URI,
    projection, null, null, null);
  mCur.moveToFirst();
  int titleIdx = mCur.getColumnIndex(Browser.BookmarkColumns.TITLE);
  int urlIdx = mCur.getColumnIndex(Browser.BookmarkColumns.URL);
  while (mCur.isAfterLast() == false) {
   tv.append("\n" + mCur.getString(titleIdx));
   tv.append("\n" + mCur.getString(urlIdx));
   mCur.moveToNext();
  }

 

 <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3