[置頂] Android Journal



========================================================================================================html

注:

本文內容轉載自互聯網,僅供我的學習之用!java

========================================================================================================android


(1)  Application does not specify an API level requirement!app

    在運行Android程序時,有時候會出現如下提示

[2010-05-28 19:03:03 - rss_reader]WARNING: Application does not specify an API level requirement!eclipse

[2010-05-28 19:03:03 - rss_reader]Device API version is 12 (Android 3.1)

    其中Android 3.1表示工程使用的Androidsdk版本,示例中使用的是3.1版本;12是設備的API版本,出現該提示,是由於工程中沒有配置設備API版本,只須要在文件AndroidManifest.xml中添加上相應的配置信息便可。
    示例以下:ide

<manifest ……>
    <application ……">
        ……
    </application>
     <uses-sdk android:minSdkVersion="12"></uses-sdk>
</manifest>

    注意,紅字部分是採用的設備API版本號;users-sdk節點同application節點在同一級別。學習



(2)  顯示尺寸的單位: ui

Difference between px, dp, dip and sp in Android?

LinkTo:http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-androidthis

px is one pixel. scale-independent pixels ( sp ) and density-independent pixels ( dip ) you want to use sp for font sizes and dip for everything else.spa

dip==dp

from here http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.



(3)  R資源丟失的問題:

Android: R cannot be resolved to a variable

轉載自:http://hi.baidu.com/mycollection/item/5f62fbeada78120d65db00ac

Android開發過程當中,碰到R cannot be resolved to a variable的報錯信息,好像沒有很肯定的錯誤緣由,通常來講,我總結出幾個可能的解決方法,但願試過之後管用。。。

 

1. 檢查Android 的SDK是否丟失須要從新下載,檢查build path

2.確保class沒有import Android.R;

3,錯誤class引用的layout的xml文件沒有錯誤

4.檢查AndroidManifest.xml文件,裏邊的package,layout配置文件,strings.xml等的字符串所有書寫正確

5.layout的xml文件中引用的strings.xml中的字符串拼寫徹底正確

6.在layout 的xml文件手寫添加一個控件,看id可否在R.java中自動生成,若是不能,那很大可能就是這個layout 的xml文件有問題,查看格式是否使用正確,或者包含什麼非法字符串,或者調用到了不正確的字符串,等等,可使用排除法,挨個去掉控件,直到發現error message消失或者id能在R.java中自動生成。
7.刪掉gen文件夾,使R.java從新自動生成一次,若是不能生成,繼續檢查layout的xml文件是否有如上不易發覺的問題

8.Clean project ,從新build,或者從新import project。

9.重啓eclipse

10.重啓電腦,以防Android 虛擬機的問題

另注:

當引用資源變量時,如R.string.bluetooth_name,編譯程序失敗,提示如「bluetooth_name cannot be resolved or is not a field..."之類的錯誤提示,

a)  須要檢查源文件是否被誤加入「import android.R;」相似的語句,若有則刪除該語句,從新編譯程序,看是否編譯經過;

 b) 編輯./res/values/strings.xml文件,修改部分文字並保存,從新編譯程序項目;






========================================================================================================

注:

本文內容轉載自互聯網,僅供我的學習之用!

========================================================================================================


(1)  Application does not specify an API level requirement!

    在運行Android程序時,有時候會出現如下提示

[2010-05-28 19:03:03 - rss_reader]WARNING: Application does not specify an API level requirement!

[2010-05-28 19:03:03 - rss_reader]Device API version is 12 (Android 3.1)

    其中Android 3.1表示工程使用的Androidsdk版本,示例中使用的是3.1版本;12是設備的API版本,出現該提示,是由於工程中沒有配置設備API版本,只須要在文件AndroidManifest.xml中添加上相應的配置信息便可。
    示例以下:

<manifest ……>
    <application ……">
        ……
    </application>
     <uses-sdk android:minSdkVersion="12"></uses-sdk>
</manifest>

    注意,紅字部分是採用的設備API版本號;users-sdk節點同application節點在同一級別。



(2)  顯示尺寸的單位: 

Difference between px, dp, dip and sp in Android?

LinkTo:http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android

px is one pixel. scale-independent pixels ( sp ) and density-independent pixels ( dip ) you want to use sp for font sizes and dip for everything else.

dip==dp

from here http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.



(3)  R資源丟失的問題:

Android: R cannot be resolved to a variable

轉載自:http://hi.baidu.com/mycollection/item/5f62fbeada78120d65db00ac

Android開發過程當中,碰到R cannot be resolved to a variable的報錯信息,好像沒有很肯定的錯誤緣由,通常來講,我總結出幾個可能的解決方法,但願試過之後管用。。。

 

1. 檢查Android 的SDK是否丟失須要從新下載,檢查build path

2.確保class沒有import Android.R;

3,錯誤class引用的layout的xml文件沒有錯誤

4.檢查AndroidManifest.xml文件,裏邊的package,layout配置文件,strings.xml等的字符串所有書寫正確

5.layout的xml文件中引用的strings.xml中的字符串拼寫徹底正確

6.在layout 的xml文件手寫添加一個控件,看id可否在R.java中自動生成,若是不能,那很大可能就是這個layout 的xml文件有問題,查看格式是否使用正確,或者包含什麼非法字符串,或者調用到了不正確的字符串,等等,可使用排除法,挨個去掉控件,直到發現error message消失或者id能在R.java中自動生成。
7.刪掉gen文件夾,使R.java從新自動生成一次,若是不能生成,繼續檢查layout的xml文件是否有如上不易發覺的問題

8.Clean project ,從新build,或者從新import project。

9.重啓eclipse

10.重啓電腦,以防Android 虛擬機的問題

另注:

當引用資源變量時,如R.string.bluetooth_name,編譯程序失敗,提示如「bluetooth_name cannot be resolved or is not a field..."之類的錯誤提示,須要檢查源文件是否被誤加入「import android.R;」相似的語句,若有則刪除該語句,從新編譯程序便可正常。

相關文章
相關標籤/搜索