有用的Andr​​oid系统资源有用、系统资源、Andr、oid

2023-09-05 05:35:49 作者:xx是个可爱鬼

Android自带有大量的系统资源( 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提供的是本地化的字符串( 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(特别是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.