技术群里面获取的小知识(一)

来源:互联网 发布:linux的可执行文件 编辑:程序博客网 时间:2024/05/11 12:04

volley框架 是开了四个线程去跟服务器交互的。在onResponse里面,就又回到了主线程,这样我们就可以操作UI了;


安卓里如何实现定时的功能,我需要每隔一段时间采集一下各种传感器的数据:采用定时器:timer;


清除自己app的通知栏可以在发送通知的时候在intent中携带id,然后在广播中拿到id清除通知栏的对应的信息;


自定义一个Toast,布局里面的控件内容我怎么在代码里面改动啊?例如我下布局里面有一个Textview,我想改变内容怎么写:

View view = getLayoutInflater().inflate(R.layout.toast_content_view, null, false);
mToast = new Toast(getApplicationContext());
mToast.setView(view);
View v = mToast.getView();
((TextView) v.findViewById(R.id.toast_view)).setText(txt);


vitamio 视频的呢  切换全屏的代码片段:

mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0); //全屏


搜索下的文字漂浮用什么实现的:android标签


图片压缩 :

public Bitmap revitionImageSize(String path) throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(
new File(path)));
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(in, null, options);
in.close();
int i = 0;
Bitmap bitmap = null;
while (true) {
if ((options.outWidth >> i <= 256)
&& (options.outHeight >> i <= 256)) {
in = new BufferedInputStream(
new FileInputStream(new File(path)));
options.inSampleSize = (int) Math.pow(2.0D, i);
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeStream(in, null, options);
break;
}
i += 1;
}
return bitmap;
}



0 0