android-R.integer

来源:互联网 发布:焦虑思维 知乎 编辑:程序博客网 时间:2024/06/16 11:13

R.integer

public static final class R.integer 
extends Object 

java.lang.Object   ↳android.R.integer

Summary


Constants

intconfig_longAnimTime

The duration (in milliseconds) of a long animation.

intconfig_mediumAnimTime

The duration (in milliseconds) of a medium-length animation.

int config_shortAnimTime

The duration (in milliseconds) of a short animation.

intstatus_bar_notification_info_maxnum

Maximum numerical value that will be shown in a status bar notification icon or in the notification itself.

Public constructors

R.integer()

Inherited methods

From class java.lang.Object

Constants


config_longAnimTime

Added in API level 3
int config_longAnimTime

The duration (in milliseconds) of a long animation.

Constant Value: 17694722 (0x010e0002)

config_mediumAnimTime

Added in API level 3
int config_mediumAnimTime

The duration (in milliseconds) of a medium-length animation.

Constant Value: 17694721 (0x010e0001)

config_shortAnimTime

Added in API level 3
int config_shortAnimTime

The duration (in milliseconds) of a short animation.

Constant Value: 17694720 (0x010e0000)

status_bar_notification_info_maxnum

Added in API level 14
int status_bar_notification_info_maxnum

Maximum numerical value that will be shown in a status bar notification icon or in the notification itself. Will be replaced with @string/status_bar_notification_info_overflow when shown in the UI.

Constant Value: 17694723 (0x010e0003)

整数型资源

XML中定义的整数。

注意:整数是一个简单的资源,用name属性提供的值来引用资源。如,能够把整数型资源跟其他简单的资源组合在一个XML文件的<resources>元素下。

文件位置(FILE LOCATION):

res/values/filename.xml

文件名是任意的,<integer>元素的name属性值被用于资源ID

资源引用(RESOURCE REFERENCE):

Java代码中:R.integer.integer_name

XML中:@[package:]integer/integer_name

语法(SYNTAX):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    
<integer
        
name="integer_name"
        
>integer</integer>
</resources>

元素(ELEMENTS):

<resources>

必须的,它必须是根节点,没有属性。

<integer>

它声明一个整数。

属性(ATTRIBUTES):

name

字符串值,它给整数定义了一个名称,它的值被用于资源ID

例子(EXAMPLE):

以下XML保存在res/values/integers.xml文件中:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    
<integer name="max_speed">75</integer>
    
<integer name="min_speed">5</integer>
</resources>

以下是应用程序代码获取整数的方法:

Resources res =getResources();
int maxSpeed = res.getInteger(R.integer.max_speed);

Integer Array型资源:

XML中定义一个整数数组。

注意:整数数组是种简单资源,用name属性提供的值来应用资源。如,能够把整数数组跟其他类型的简单资源一起组合到一个XML文件的<resources>元素下。

文件位置(FILE LOCATION):

res/values/filename.xml

文件名是任意的。<integer-array>元素的name属性值被用作资源ID

被编译资源的数据类型(COMPILED RESOURCE DATATYPE):

资源指向一个整数数组。

资源应用(RESOURCE REFERENCE):

Java代码中:R.array.integer_array_name

XML中:@[package:]array.integer_array_name

语法(SYNTAX):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    
<integer-array
        
name="integer_array_name">
        
<item
            
>integer</item>
    
</integer-array>
</resources>

元素(ELEMENTS):

<resources>

必须的,它必须是根节点,没有属性。

<string-array>

它定义一个整数数组,包含一个或多个<item>子元素。

属性(ATTRIBUTES):

android:name

字符串值,给数组定义一个名称。这个名称被用作资源ID

<item>

定义一个整数。它的值能够是另一个整数资源的引用。它必须是<integer-array>元素的子元素,没有属性。

例子(EXAMPLE):

以下XML定义被保存在res/values/integers.xml文件中:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    
<integer-array name="bits">
        
<item>4</item>
        
<item>8</item>
        
<item>16</item>
        
<item>32</item>
    
</integer-array>
</resources>

以下是应用程序中代码获取整数数组的方法:

Resources res =getResources();
int[] bits = res.getIntArray(R.array.bits);


详细使用方法:

一、float的配置方法 

   andriod 默认不支持float型的设置,在values 下的新建floats.xml 文件,在内部添加如下代码:

<resources>      <item name="chart_view_line_width" format="float" type="dimen"> 3.3</item>      <item name="chart_view_text_size" format="float" type="dimen">17</item>  </resources>

   在代码中的使用方法是:

r.setLineWidth(Float.parseFloat(mContext.getResources().getString(R.string.chart_view_line_width)));  r.setChartValuesTextSize(Float.parseFloat(mContext.getResources().getString(R.string.chart_view_text_size)));

二、integer的配置方法

   android 默认支持integer形的设置,在values下新建integers.xml文件,如下:

复制代码
<resources>      <integer name="emotion_columm_num">14</integer>      <integer name="right_icon_visibility">0</integer>      <integer name="webview_fix_height">65</integer>      <integer name="right_icon_orientation">1</integer>      <integer name="dashboard_flip_interval">4000</integer>      <integer name="pairing_duration">100</integer></resources>
复制代码

代码中使用是:

复制代码
<?xml version="1.0" encoding="utf-8"?>  <animation-list xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/select"      android:oneshot="false" >        <item          android:drawable="@drawable/pairing_01"          android:duration="@integer/pairing_duration"/>      <item          android:drawable="@drawable/pairing_02"          android:duration="@integer/pairing_duration"/>      <item          android:drawable="@drawable/pairing_03"          android:duration="@integer/pairing_duration"/>    </animation-list>
复制代码

mContext.getResources().getInteger(R.integer.columns);



0 0
原创粉丝点击