- 浏览: 192099 次
- 性别:
- 来自: 深圳
最新评论
-
0dragon:
挺多 我试试先
android 状态栏(StatusBar) -
z494627:
这个加速插件是做什么用的?
Ubuntu10.04 搭建android平台
编写了一个简单的Android 程序来读取android系统中的图标,为大家android编程过程中系统图标引用提供方便:
Activity代码
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; import com.gionee.icon.R; public class AndroidImageActivity extends Activity { private Gallery gallery; private ImageView imageview; private ImageAdapter imageadapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); imageadapter=new ImageAdapter(this); /* 通过findViewById 取得 资源对象*/ gallery=(Gallery)findViewById(R.id. Gallery_preView); imageview=(ImageView)findViewById(R.id. ImageView_photo ); /*给Gallery设置适配器 把Ex_Ctrl_10ME类传入参数*/ gallery.setAdapter(imageadapter); /*设置Gallery的点击事件监听器*/ gallery.setOnItemClickListener(new Gallery.OnItemClickListener(){ public void onItemClick(AdapterView<?> parent, View v, int position,long id) { /*显示该图片是几号*/ Toast.makeText(AndroidImageActivity.this,"图片:" + imageadapter.map.get(position).get("name").toString(), Toast.LENGTH_SHORT).show(); /*设置大图片*/ imageview.setBackgroundResource(Integer.parseInt(imageadapter.map.get(position).get("id").toString())); } }); } }
图片适配器代码:
import android.content.Context; import android.content.res.TypedArray; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; import java.util.ArrayList; import java.util.HashMap; public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; public ArrayList<HashMap<String, Object>> map; public ImageAdapter(Context context) { this.mContext = context; /* * 使用在res/values/attrs.xml 中的<declare-styleable>定义 的Gallery 属性. */ TypedArray typed_array = context.obtainStyledAttributes(R.styleable.Gallery); /* 取得Gallery 属性的Index id */ mGalleryItemBackground = typed_array.getResourceId( R.styleable.Gallery_android_galleryItemBackground, 0); /* 让对象的styleable 属性能够反复使用 */ typed_array.recycle(); ReadProperties rp = new ReadProperties(); map = rp.getImage(mContext); } @Override public int getCount() { return map.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { /* 产生ImageView 对象 */ ImageView imageview = new ImageView(mContext); /* 设置图片给imageView 对象 */ imageview.setImageResource(Integer.parseInt(map.get(position).get("id").toString())); /* 重新设置图片的宽高 */ imageview.setScaleType(ImageView.ScaleType.FIT_XY); /* 重新设置Layout 的宽高 */ imageview.setLayoutParams(new Gallery.LayoutParams(80, 80)); /* 设置Gallery 背景图 */ imageview.setBackgroundResource(mGalleryItemBackground); /* 返回imageView 对象 */ return imageview; } }
读取配置文件:
import android.content.Context; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Properties; public class ReadProperties { @SuppressWarnings("unchecked") public ArrayList<HashMap<String, Object>> getImage(Context context) { ArrayList<HashMap<String, Object>> image_map = new ArrayList<HashMap<String, Object>>(); Properties pro = new Properties(); InputStream is; try { is = context.getResources().openRawResource(R.raw.info); pro.load(is); } catch (IOException e) { e.printStackTrace(); } //返回属性列表中所有键的枚举,如果在主属性列表中未找到同名的键,则包括默认属性列表中不同的键 Enumeration<String> enumvalue = (Enumeration<String>) pro.propertyNames(); while(enumvalue.hasMoreElements()) { HashMap<String, Object> map = new HashMap<String, Object>(); String key = enumvalue.nextElement(); String value = pro.getProperty(key); map.put("name", "android.R.drawable" + key); map.put("id", value); image_map.add(map); } return image_map; } }
配置文件:放置在res/raw/info.properties
(因为文件有点大就不写出内容了)
- AndroidImage.tar (180 KB)
- 下载次数: 28
发表评论
-
adb logcat
2013-09-24 09:22 0android adb 使用教程: http://www.os ... -
(转)android中如何获得webView中的内容
2013-05-02 16:43 1188本文概要:在程序中经常会用到webView来显示网页,但如果 ... -
(转)【Android】Paint的效果研究
2013-04-15 15:44 34750在Paint中有很多的属性可以设置,比如可以设置阴影, ... -
(转)Android 四种launchMode
2013-04-08 15:55 10711,standard 每次都会新建 ... -
(转)Android TextView中链接(link)点击事件的截取
2013-04-08 10:58 2153布局文件xml 1 <TextView 2 ... -
Android JNI介绍
2013-01-17 19:44 3080附:相关代码路径 /fr ... -
区分Activity的四种加载模式
2013-01-06 19:19 0在多Activity开发中,有 ... -
android Makefile学习总结
2012-12-17 12:07 0(1)build.prop是如何生成的 Android 的 ... -
Ubuntu10.04 搭建android平台
2012-12-03 13:02 1176转自:http://www.cnblogs.com/Wonde ... -
Android SDK中tools详解
2012-11-29 09:48 0Android SDK包含了各种各 ... -
在Eclipse中查看Android源码
2012-11-16 11:32 992两件事的解决办法: ... -
Android中的长度单位
2012-11-09 11:02 995dp 和 sp px:表示屏幕实 ... -
Android自动化压力测试图解教程——Monkey工具
2012-10-31 11:10 4392有时候我们需要对一个软件进行压力测试,检查该软件的性能。如果是 ... -
Android 移动终端camera 防偷*拍设置
2012-09-28 16:14 2475目前市面上的所有移动终端几乎都有camera 应用,但A ... -
(转)【流媒體】Android 实时视频采集—Cameara预览采集
2012-09-25 13:54 146291 概述 通过Android Camera拍摄预览中设置se ... -
(转)android CAMERA 设置照片大小
2012-09-25 12:05 5165最近在 REAL210 android 上调试 CAMERA ... -
(转)Camera构架分析
2012-09-24 13:40 1604一.Camera构架分析 Android ... -
(转)Android Camera 开发之前言
2012-09-24 10:15 1740一、 Android Camera 成像原理介绍 ... -
(转)使用Memory Analyzer tool(MAT)分析内存泄漏
2012-08-09 15:14 1095前言 在平时工作 ... -
(转)Android NDK HelloJNI
2012-07-18 14:10 1581入门的最好办法就是学习Android自带的例子, 这里就通过学 ...
相关推荐
android 系统图标文件打包,有些图标确实挺好看的,省了大家不少事,而且各个状态都有。
用于设计师们在进行Android系统图标设计时使用的相关设计规范
内为android系统自带的小图标,很全,九宫格处理过
android系统中自带的图标大全,android系统中自带的图标大全。
Android所有系统资源图标android.R.drawable.xxx查看软件 源码地址:http://blog.csdn.net/dianyueneo/article/details/7197067
Moto android2.2手机上的系统图标,比android默认的图标好看多了。
android操作系统内带的图标,可以直接用。
Android系统图标android.R.drawable下的所有图标查看软件
android开发图标大全(很多的图标)
最全android的系统图标
Android教您如何使用系统图标定义ImageButton,对于网上流传的关于imagebutton的使用过程大多雷同且不细致,时常出错,本代码已经验证运行,效果还不错!
android 系统桌面logo增加消息角标功能,解决目前android系统只有小米等几类手机有消息角标,华为、三星等手机。。
Android系统原生图标集合 Android开发必备
android 8.0系统应用图标适配步骤:1.新建一个android项目2.新建的android项目AndroidManifest.xml里面android:
windowxp系统图标 可用于做android系统图标
android 图片 android 系统图标
包含android系统自带的,免费公开的icons集合,有每个图标的样式和英文名称,包括桌面的,menu菜单里的所有图标,使用时不用下载,直接通过代码引用即可。