熟女俱乐部五十路二区av,又爽又黄禁片视频1000免费,国产卡一卡二卡三无线乱码新区,中文无码一区二区不卡αv,中文在线中文a

新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > Android常見錯誤匯總

Android常見錯誤匯總

作者: 時間:2016-10-08 來源:網(wǎng)絡 收藏

16.交互性的button定義的方法:

首先是準備好按鈕不同狀態(tài)的圖片

然后 在res/drawable中定義selector的xml文件

最后Button的background屬性中設置

android:id=@+id/btnAdd

android:layout_width=wrap_content

android:layout_height=wrap_content

android:background=@drawable/addbtn_selector/>

17在超級終端中執(zhí)行程序報錯-Permission deny

參照http://android.stackexchange.com ... fo-on-error-message

主要原因是不能在sdcard中執(zhí)行,直接進入data/目錄下面創(chuàng)建文件,然后執(zhí)行就可以了。

18.從svn導入工程項目有驚嘆號

錯誤提示Archive for required library: 'libs/armeabi/libvudroid.so' in project 'DocumentViewer' cannot be read or is not a valid ZIP file

主要是路徑出了問題

解決方法:在project的build-path將外部包(庫)的引用刪掉就可以了。

19.首次進入帶有EditText的Activity不自動彈出軟鍵盤,再次點擊才彈出。

只有設置manifest的方法有用,在activity的設置中添加:

[html] view plaincopyprint?

android:windowSoftInputMode=adjustPan|stateHidden

20.Gallery中OnItemClickListener與OnItemSelectedListener的區(qū)別

OnItemClickListener:只有單擊Gallery中的View才會觸發(fā)事件,準確的說是當點擊之后抬起手的時候觸發(fā),滑動不會觸發(fā)。

OnItemSelectedListener:當Gallery中的View被選中的時候就會觸發(fā),Galler初次顯示就會觸發(fā)一次,選中第一個iew,滑動和單擊都會觸發(fā)。

20.從16進制中提取顏色的rgb分量。

主要就是通過位運算來實現(xiàn)。

[java] view plaincopyprint?

public class Main {

public static void main(String[] args) {

// TODO Auto-generated method stub

int INK_COLOR = 0xFF11ef23;

float r = getColorR(INK_COLOR );

float g = getColorG(INK_COLOR );

float b = getColorB(INK_COLOR );

System.out.print(r+ +g+ +b);

}

public static float getColorR(int c)

{

int R = (c 0x00FF0000 )>>16;

return (float) (R/255.0);

}

public static float getColorG(int c)

{

int G =(c 0x0000FF00 )>>8;

return (float) (G/255.0);

}

public static float getColorB(int c)

{

int B = c 0x000000FF;

return (float) (B/255.0);

}

}

21. Eclipse中簽名導出apk崩潰,手動簽名。

工程沒問題,調試也沒問題,但打包的時候eclipse會崩潰,解決方法是手動打包。

首先去工程目錄下的bin文件夾下找到apk文件,解壓后刪除META-INF文件夾,重新打包成壓縮包,改后綴名為.apk

首先是簽名(假設你已經(jīng)在根目錄下生產(chǎn)了密鑰keystore):

進入java安裝目錄/bin文件夾下:

[plain] view plaincopyprint?

./jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore android.keystore ~/Output.apk android

然后是優(yōu)化,進入sdk的tools文件夾下,運行。

[plain] view plaincopyprint?

./zipalign -v 4 ~/Output.apk Output_realase.apk

當前目錄下Output_realase.apk就是打包簽名好的apk了。

22.android.view.InflateException: Binary XML file line #異常的解決

創(chuàng)建自定義view的時候,碰到 android.view.InflateException: Binary XML file line #異常,反復研究

后發(fā)現(xiàn)是缺少一個構造器造成。

[java] view plaincopyprint?

public MyView(Context context,AttributeSet paramAttributeSet)

{

super(context,paramAttributeSet);

}

補齊這個構造器,異常就消失了.

23.將assets文件夾中的壓縮包拷貝到sdcard中(不限大小)

[java] view plaincopyprint?

public static void copyAssetToSdcard(Context c, String assetFile, String destination) throws IOException {

InputStream in = c.getAssets().open(assetFile);

File outFile = new File(destination);

OutputStream out;

Log.v(Try, Try coping.);

try {

if (!(new File(destination)).exists()) {

Log.v(Try, Not exists..);

out = new FileOutputStream(outFile);

copyFile(in, out);

in.close();

in = null;

out.flush();

out.close();

out = null;

}

} catch (Exception e) {

Log.v(Error, Error in if。);

}

}

public static void copyFile(InputStream in, OutputStream out) throws IOException {

Log.v(Coping, copyFiling.);

byte[] buffer = new byte[1024];

int read;

while ((read = in.read(buffer)) != -1) {

Log.v(read:, + read);



關鍵詞:

評論


相關推薦

技術專區(qū)

關閉