简体   繁体   English

Android系统资源动态获取文本

[英]Android System Resources Get Text dynamically

I would like to set some specific system settings of android within my application. 我想在我的应用程序中设置一些特定的android系统设置。 Is it possible to get the text and maybe also a description of the settings resources by code? 是否可以通过代码获取文本以及设置资源的描述?

For instance I would like to allow to change this setting: 例如,我想允许更改此设置:

android.provider.Settings.System.SCREEN_BRIGHTNESS In the android settings it appears Brighness. android.provider.Settings.System.SCREEN_BRIGHTNESS在android设置中显示为Brighness。 This resource is localized as well, so I do not want to do the same thing within my appliacation. 此资源也已本地化,因此我不想在自己的应用程序中执行相同的操作。 I would like to create a button and insert the text dynamically, if possible. 如果可能,我想创建一个按钮并动态插入文本。

If someone has a hint were to look at, please help. 如果有人暗示要看,请帮助。

Best Regards, 最好的祝福,

Patrick 帕特里克

android.provider.Settings.System.SCREEN_BRIGHTNESS In the android settings it appears Brighness. android.provider.Settings.System.SCREEN_BRIGHTNESS在android设置中显示为Brighness。 This resource is localized as well, so I do not want to do the same thing within my appliacation. 此资源也已本地化,因此我不想在自己的应用程序中执行相同的操作。

See this: Settings.System . 参见: Settings.System If you want the value localized, use an integer resource in folders with language and/or locale qualifiers. 如果要将值本地化,请在具有语言和/或区域限定符的文件夹中使用整数资源。 See Integer Resource and Alternative Resources 请参阅整数资源替代资源

I would like to create a button and insert the text dynamically, if possible. 如果可能,我想创建一个按钮并动态插入文本。

Define as much of the layout as possible in xml, calling setContentView() on the name of the xml file. 在xml中定义尽可能多的布局,在xml文件的名称上调用setContentView()。 The button can then be referenced after the call with (Button)findViewById() using the id as given in xml. 然后可以在调用之后使用(Button)findViewById()使用xml中给出的ID来引用该按钮。 You can then set text dynamically and modify the widget further in code. 然后,您可以动态设置文本并在代码中进一步修改小部件。 See Layouts and TextView setText , which works for Button since Button extends TextView. 请参见LayoutsTextView setText ,它适用于Button,因为Button扩展了TextView。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM