android系统中DP和SP的转化:1.首先分析TypedValue.java可以调用以下代码获得dp的值TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20,getResources().getDisplayMetrics());pu...
分类:
移动开发 时间:
2015-09-07 21:17:17
阅读次数:
243
R.drawable.xx是特殊的int型,存入数据库需要处理intbgid=this.getResources().getIdentifier("date","drawable",getPackageName());if(R.drawabke.date==bgid){setbackground(bg.id);}是不是很简单,可以存入数据库!
分类:
数据库 时间:
2015-09-03 11:39:24
阅读次数:
224
项目遇到,gridview有一个item是点击后选择的,但又新的item加如后这个就不断向后移动
在adapter中将返回的项数加一
if(positionmSelectPath.size()){
//添加list中的数据
}else {
image.setImageDrawable(mContext.getResources().getDrawable(R.mip...
分类:
其他好文 时间:
2015-08-31 19:43:40
阅读次数:
157
我们在使用Spring时可以指定一个名包,Spring可以自动扫描出该包下的所有组件。通过翻阅Spring源码,其实这个功能不难实现。首先,所有在classpath下的资源(文件),都是可以被ClassLoader加载的。我们可以调用它的getResources()方法加载类路径下的文件:public Enumeration getResources(String name)...
分类:
编程语言 时间:
2015-08-29 14:05:26
阅读次数:
214
在插件中或者library的项目中把文件放在asstes,不能用context.getResources().getAssets().open(fileName)读取到流,会报FileNotFoundException.有两种方式解决1.把需要的读取的文件放在主程序的asstes文件夹中,缺点就是要...
分类:
移动开发 时间:
2015-08-28 10:50:47
阅读次数:
136
经常会用到将ActionBar文字居中的问题,这里写个代码如下:
//把actionBar的文字标题居中
public static void centerActionBarTitle(Activity activity)
{
int titleId = activity.getResources().getIdentifier("action_bar_t...
分类:
移动开发 时间:
2015-08-27 21:17:13
阅读次数:
329
public class AssetsUtil
{
public static byte[] getAssertsFileInBytes(String assetsFileName) {
InputStream is;
try {
is = DpApp.getContext().getResources().getAssets(...
分类:
其他好文 时间:
2015-08-27 15:34:05
阅读次数:
269
只需三行代码:Resources resources = getBaseContext().getResources();
Drawable imageDrawable = resources.getDrawable(R.drawable.background_image); //图片在drawable目录下
mImageView.setBackgroundDrawable(imageDraw...
分类:
其他好文 时间:
2015-08-19 11:14:19
阅读次数:
172
原文链接:http://www.2cto.com/kf/201312/265180.html
全都是一些代码片段,需要可以直接贴过去用
/** 获取 drawable 的图片 可以循环 1.图名 2.drawable 3.包名 **/
int imgid = getResources().getIdentifier("ic_launcher", ...
分类:
移动开发 时间:
2015-08-19 07:07:38
阅读次数:
138
1、使用Resources 类的 getIdentifier方法 Resources res=getResources(); return res.getIdentifier(type,"drawable",getPackageName()); //这里type代表变量名称,getPackage.....
分类:
其他好文 时间:
2015-08-18 18:35:49
阅读次数:
105