使用系统映像[否图片及QUOT; Android上的通讯录 [英] Using the system image for "no picture" contacts on Android

查看:138
本文介绍了使用系统映像[否图片及QUOT; Android上的通讯录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现<一个href=\"http://stackoverflow.com/questions/6256716/using-the-default-contact-picker-photo-in-my-app\">this问题这是我想解决同样的问题。

I found this question which is the same problem that I would like to address.

读他的问题和接受的答案,虽然,它听起来就像他的做法是拉从资源的实际图像文件,将它嵌入到他的应用,并使用它作为一个本地资源。

Reading his question and the accepted answer though, it sound like his approach was to pull the actual image file from the resources, embed it in his app and use it as a local resource.

我想preFER要能够做的就是在源属性我的形象,用一个ID这样可以让我拉的形象从本地系统,让我的应用程序是否在运行ICS ,HC,GB或升级Froyo,或者如果该设备的制造商已改变了Android源代码,其中包括空联系人照片自己的形象,我的应用程序将永远是使用适当的之一,从它的系统是在时间上运行。

What I'd prefer to be able to do is in the source property for my image, use an ID which would allow me to pull that image from the local system, so that whether my app is running on ICS, HC, GB or Froyo, or if the manufacturer of the device has altered the Android source and included their own image for empty contact photos, that my app would always be using the appropriate one, from the system it is running on at the time.

假的东西codeD这样的:

Something pseudo-coded like:

if(user.NoPhoto) {
    img.src = loadImageFromId(android.R.drawable.ContactWithoutPhoto)  
}

同样的方式,可以使用平台的样式和字符串在你的应用程序。结果
有没有无照片接触式图像标准的ID,希望希望??

The same way you can use platform styles and strings in your app.
Is there a standard ID for the no-photo contact image, hope hope??

推荐答案

不幸的是那张照片是不公开的。

Unfortunately that picture is not public.

你能做的唯一一件事就是创建以下文件夹和图像从SDK复制到项目:

The only thing you can do is to create the following folders and copy the image from the SDK into your project:


  • 有关的Andr​​oid 3.0及更高版本:绘制-xhdpi-V11 绘制-HDPI-V11 绘制-MDPI-V11 绘制-LDPI-V11

  • 对于Android 2.3的:绘制-xhdpi-V9 绘制-HDPI-V9 绘制-MDPI-V9 绘制-LDPI-V9

  • 对于previous版本:绘制-xhdpi 绘制,华电国际绘制-MDPI 绘制-LDPI

  • For Android 3.0 and later: drawable-xhdpi-v11, drawable-hdpi-v11,drawable-mdpi-v11, and drawable-ldpi-v11.
  • For Android 2.3 :drawable-xhdpi-v9, drawable-hdpi-v9, drawable-mdpi-v9, and drawable-ldpi-v9.
  • For previous versions: drawable-xhdpi, drawable-hdpi, drawable-mdpi, and drawable-ldpi.

系统会为您选择合适的图像和code以下将正常工作。

The system will select the right image for you and the code below will work fine.

if(user.NoPhoto) {
    img.setImageResource(R.drawable.ic_contact_picture);  
}

这篇关于使用系统映像[否图片及QUOT; Android上的通讯录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆