有用的Andr​​oid系统资源 [英] Useful Android system resources

查看:169
本文介绍了有用的Andr​​oid系统资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android自带有大量的系统资源(<$ C C $> android.R ),可以用来为您节省时间,让您的应用程序更亮。

Android comes with lots of system resources (android.R) that can be used to save you time and make your application lighter.

例如,我最近发现,Android提供的是本地化的字符串(<$ C C $> android.R.string.yes ),否( android.R .string.no ),取消( android.R.string.cancel )和确定( android.R.string .ok ),其他串之间。

For example, I recently discovered that Android provides localized strings for Yes (android.R.string.yes), No (android.R.string.no), Cancel (android.R.string.cancel) and Ok (android.R.string.ok), among other strings.

你们推荐使用哪些系统资源?或者是有一个理由,以避免使用系统资源?

What other system resources do you recommend using? Or is there a reason to avoid using system resources?

编辑:正如由Tomas,一些这方面的资源可能不会产生效果,你会期望(特别是 android.R.string.yes /没有返回确定/取消而不是是/否,作为报道的这里)。为了更好地控制,您可以从Android源$ C ​​$ C复制的系统资源。

As noted by Tomas, some of this resources might not produce the results you would expect (particularly, android.R.string.yes/no returns OK/Cancel instead of Yes/No, as reported here). For greater control, you can copy system resources from the Android source code.

推荐答案

您可以找到所有系统资源的的 Android包

You can find a full listing of all system resources in the android package.

每当我想要做的事情在Android上我检查,看看是否有一个系统资源,涵盖了我想做的事情。它有利于导入Android源$ C ​​$ C(特别是<一个href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=core/res/res;h=a3562fe1af94134486a8a899f02a9c2f7986c8dd;hb=HEAD">their / RES /文件夹)在搜索已实现的资源时,你可能想要的,所以你可以看到他们的具体执行情况。

Every time I want to do something on Android I check to see if there's a system resource that covers what I want to do. It is helpful to import the Android source code (in particular, their /res/ folder) when searching for already-implemented resources that you might want, so you can see their specific implementation.

就个人而言,我发现自己最经常使用:

Personally, I find myself most often using:

  • 内置Android布局标准的任务,如微调的下拉列表中。
  • 在Android的IDS( android.R.id ),因为你经常需要,如果你想使用一些Android的小部件(例如使用这些, TabHost / TabWidget 您需要使用机器人:ID / tabhost 机器人:ID /标签机器人:ID / tabcontent 如果你想要实现一个XML布局)
  • 内置的色彩,尤其是 android.R.color.transparent
  • 在Android的内置淡入和淡出的动画在 android.R.anim
  • Built-in Android layouts for standard tasks, such as spinner dropdowns.
  • Android ids (android.R.id), because you are often required to use these if you want to use some of Android's widgets (for example, TabHost/TabWidget requires you to use "android:id/tabhost", "android:id/tabs" and "android:id/tabcontent" if you want to implement an XML layout).
  • Built-in colors, especially android.R.color.transparent.
  • Android's built-in fade-in and fade-out animations in android.R.anim.

这篇关于有用的Andr​​oid系统资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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