当前位置: 编程技术>移动开发
本页文章导读:
▪见习2天的总结 实习2天的总结
1、long start = System.currentTimeMillis();以毫秒的形式获取当前时间。
2、ReentrantLock 将由最近成功获得锁,并且还没有释放该锁的线程所拥有。当锁没有被另一个线程所拥有时,调用.........
▪ 兑现的Gallery加载网络图片 实现的Gallery加载网络图片
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //不显示程序的标题栏 requestWindowFeature(Window.FEATURE_NO_TITLE); .........
▪ JNI有关参考文献 JNI相关参考文献
JNI相关参考文献,学习android jni 的同学可以下载下来看看!
......
[1]见习2天的总结
来源: 互联网 发布时间: 2014-02-18
实习2天的总结
1、long start = System.currentTimeMillis();以毫秒的形式获取当前时间。
2、ReentrantLock 将由最近成功获得锁,并且还没有释放该锁的线程所拥有。当锁没有被另一个线程所拥有时,调用 lock 的线程将成功获取该锁并返回。如果当前线程已经拥有该锁,此方法将立即返回。可以使用 isHeldByCurrentThread() 和 getHoldCount() 方法来检查此情况是否发生。
3、ByteArrayOutputStream out = req.getBytes();
byte[] buf = out.toByteArray();
创建一个新分配的 byte 数组。其大小是此输出流的当前大小,并且缓冲区的有效内容已复制到该数组中。
4、 ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(out);
创建一个新的数据输出流,将数据写入指定基础输出流。
5、readInt()读取四个输入字节并返回一个int值。
readByte()读取并返回一个输入字节
readLong()读取八个输入字节并返回一个Long值
readDouble()读取八个输入字节并返回一个Double值
readFloat()读取八个输入字节并返回一个Float值
6、 read()从输入流中读取下一个数据字节
7、一个大类里面包含很多的内部静态类,这样做的目的就是尽量把一些有关联的类放在一起,以免写过多的零散的小类
[2] 兑现的Gallery加载网络图片
来源: 互联网 发布时间: 2014-02-18
实现的Gallery加载网络图片
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//不显示程序的标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
//不显示系统的标题栏
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,WindowManager.LayoutParams. FLAG_FULLSCREEN);
setContentView(R.layout.main);
WindowManager windowmanager = getWindowManager();
Display display = windowmanager.getDefaultDisplay();
SCREEN_WIDTH = display.getWidth();
SCREEN_HEIGHT = display.getHeight();
//引用gallery组件
Gallery g = (Gallery) findViewById(R.id.gallery);
//在此下面定制适配器
g.setAdapter(new ImageAdapter(this));
//设置画廊中的图片边距
g.setSpacing(2);
g.setOnItemSelectedListener(this);
imageview[0] = (ImageView) findViewById(R.id.imageView1);
imageview[1] = (ImageView) findViewById(R.id.imageView2);
imageview[2] = (ImageView) findViewById(R.id.imageView3);
imageview[3] = (ImageView) findViewById(R.id.imageView4);
imageview[4] = (ImageView) findViewById(R.id.imageView5);
imageview[5] = (ImageView) findViewById(R.id.imageView6);
imageview[6] = (ImageView) findViewById(R.id.imageView7);
tv = (TextView) findViewById(R.id.text);
//设置一个itemclicklistener,
g.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView parent, View v, int position,
long id) {
//注释后 未显示短按组件
Toast.makeText(testgallery.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
}
public class ImageAdapter extends BaseAdapter{
int mGalleryItemBackground;
private Context mContext;
public ImageAdapter(Context c){
mContext = c;
}
public int getCount() {
return imageurl.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext);
//i.setImageResource(mImageIds[position]);
/*异步进行加载*/
new Thread(){
public void run(){
URL url;
try {
if(bm[position] == null){
url = new URL(/blog_article/imageurl[position]/index.html);
bm[position] = BitmapFactory.decodeStream(url.openStream());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
if(bm[position] != null){
i.setImageBitmap(bm[position]);
}else{
i.setImageResource(mImageIds[0]);
}
i.setScaleType(ImageView.ScaleType.CENTER_CROP);//FIT_XY centerCrop
//i.setLayoutParams(new Gallery.LayoutParams(20, 20));//136 88 //图片的宽高
i.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
//设置Gallery组件的背景风格
i.setBackgroundResource(mGalleryItemBackground);
return i;
}
private String[] imageurl = {
"http://pic0.qiyipic.com/common/20110214/768e29bae49148708c8341f8781c2a0a.jpg",
"http://pic3.qiyipic.com/common/20110214/d5c22c49cce04f3d827961f9f615e9d1.jpg",
"http://sports.tom.com/uldf/2011/0213/goujianzhen/fpx.jpg",
"http://www.qiyipic.com/lvyou/fix/csmlga.jpg",
"http://www.qiyipic.com/lvyou/fix/sqxy.jpg",
"http://www.qiyipic.com/lvyou/fix/astrj.jpg",
"http://www.qiyipic.com/thumb/20110223/v73694.jpg"
};
private Integer[] mImageIds = {
R.drawable.gallery_photo_1,
R.drawable.gallery_photo_2,
R.drawable.gallery_photo_3,
R.drawable.gallery_photo_4,
R.drawable.gallery_photo_5,
R.drawable.gallery_photo_6,
R.drawable.gallery_photo_7
};
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//不显示程序的标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
//不显示系统的标题栏
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,WindowManager.LayoutParams. FLAG_FULLSCREEN);
setContentView(R.layout.main);
WindowManager windowmanager = getWindowManager();
Display display = windowmanager.getDefaultDisplay();
SCREEN_WIDTH = display.getWidth();
SCREEN_HEIGHT = display.getHeight();
//引用gallery组件
Gallery g = (Gallery) findViewById(R.id.gallery);
//在此下面定制适配器
g.setAdapter(new ImageAdapter(this));
//设置画廊中的图片边距
g.setSpacing(2);
g.setOnItemSelectedListener(this);
imageview[0] = (ImageView) findViewById(R.id.imageView1);
imageview[1] = (ImageView) findViewById(R.id.imageView2);
imageview[2] = (ImageView) findViewById(R.id.imageView3);
imageview[3] = (ImageView) findViewById(R.id.imageView4);
imageview[4] = (ImageView) findViewById(R.id.imageView5);
imageview[5] = (ImageView) findViewById(R.id.imageView6);
imageview[6] = (ImageView) findViewById(R.id.imageView7);
tv = (TextView) findViewById(R.id.text);
//设置一个itemclicklistener,
g.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView parent, View v, int position,
long id) {
//注释后 未显示短按组件
Toast.makeText(testgallery.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
}
public class ImageAdapter extends BaseAdapter{
int mGalleryItemBackground;
private Context mContext;
public ImageAdapter(Context c){
mContext = c;
}
public int getCount() {
return imageurl.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext);
//i.setImageResource(mImageIds[position]);
/*异步进行加载*/
new Thread(){
public void run(){
URL url;
try {
if(bm[position] == null){
url = new URL(/blog_article/imageurl[position]/index.html);
bm[position] = BitmapFactory.decodeStream(url.openStream());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
if(bm[position] != null){
i.setImageBitmap(bm[position]);
}else{
i.setImageResource(mImageIds[0]);
}
i.setScaleType(ImageView.ScaleType.CENTER_CROP);//FIT_XY centerCrop
//i.setLayoutParams(new Gallery.LayoutParams(20, 20));//136 88 //图片的宽高
i.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
//设置Gallery组件的背景风格
i.setBackgroundResource(mGalleryItemBackground);
return i;
}
private String[] imageurl = {
"http://pic0.qiyipic.com/common/20110214/768e29bae49148708c8341f8781c2a0a.jpg",
"http://pic3.qiyipic.com/common/20110214/d5c22c49cce04f3d827961f9f615e9d1.jpg",
"http://sports.tom.com/uldf/2011/0213/goujianzhen/fpx.jpg",
"http://www.qiyipic.com/lvyou/fix/csmlga.jpg",
"http://www.qiyipic.com/lvyou/fix/sqxy.jpg",
"http://www.qiyipic.com/lvyou/fix/astrj.jpg",
"http://www.qiyipic.com/thumb/20110223/v73694.jpg"
};
private Integer[] mImageIds = {
R.drawable.gallery_photo_1,
R.drawable.gallery_photo_2,
R.drawable.gallery_photo_3,
R.drawable.gallery_photo_4,
R.drawable.gallery_photo_5,
R.drawable.gallery_photo_6,
R.drawable.gallery_photo_7
};
}
[3] JNI有关参考文献
来源: 互联网 发布时间: 2014-02-18
JNI相关参考文献
JNI相关参考文献,学习android jni 的同学可以下载下来看看!
JNI相关参考文献,学习android jni 的同学可以下载下来看看!
最新技术文章: