Time of Update: 2018-12-03
開發Android應用中,隨著功能越來越多,啟動速度越來越慢。有沒有辦法讓自己應用啟動速度快一點呢?方法是人想出來的。先說說我的實現方法:1 將onCreate 中初始化的內容,移動到線程中做初始化,載入等2 初始化完成之後,通過Handler發送訊息,3 Hander 中收到訊息後,再初始化完整介面。通過這樣的思路,能讓介面快速顯示,而不是顯示黑屏。代碼原型:public class MainActivity extends Activity { @Override
Time of Update: 2018-12-03
android 動態換膚,Android系統已經完美解決換膚問題,看到網上好多的朋友還在詢問如何換膚。我樣本一下Android換膚看效果點擊 Day 後的主題皮膚點擊 Night後,主題皮膚package cn.hpc.assistant;import android.app.Activity;import android.content.Context;import android.graphics.PixelFormat;import
Time of Update: 2018-12-03
android-uitableview是一個仿製Iphone UI的view,介面效果不錯。Defining your layout查看源碼列印?1<br.com.dina.ui.widget.UITableView2android:id="@+id/tableView"3style="@style/UITableView"/>Working on your activity查看源碼列印?01public class Example1Activity extendsActivity
Time of Update: 2018-12-03
開發中我們需要對部分功能進行單元測試,啟動Activity來測試部分小功能,有點小題大作,殺雞用牛刀。我們可以用Android單元測試 Instrumentation本篇只是入門,起到拋磚的效果Instrumentation無介面,具有啟動能力。下面通過一個簡單的例子來講解Instrumentation的基本測試方法:我們測試工程AndroidManifest.xml<?xml version="1.0" encoding="utf-8"?><manifest
Time of Update: 2018-12-03
開發工具:eclipse 運行環境:htc G9 android2.3.3話不多說,先看其實左右邊的A~Z是一個自訂的View,它直接覆蓋在ListView上。MyLetterListView:[java] view plaincopypublic class MyLetterListView extends View { OnTouchingLetterChangedListener onTouchingLetterChangedListener;
Time of Update: 2018-12-03
mainpage.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >
Time of Update: 2018-12-03
想要做一個看新聞的應用,類似Cnbeta用戶端的東西。大致思路如下:根據連結擷取新聞列表頁的html代碼,然後解析,找到所有的新聞標題和新聞連結用listView顯示,當點擊ListView的Item再載入相應的新聞內容。其中擷取html代碼,可以使用如下代碼實現:[java] view
Time of Update: 2018-12-03
Android 開發中,java 可以方便的使用調試資訊Log.i, Log.d ...,Jni層可否使用呢?答案是肯定的。1 為方便使用,先進行宏定義:eben_hpc_log.h內容如下:#ifndef _Included_hpc_Log#define _Included_hpc_Log#ifdef __cplusplusextern "C" {#endif#include <android/log.h>// 宏定義類似java 層的定義,不同層級的Log LOGI, LOGD,
Time of Update: 2018-12-03
[java] public class HeartbeatService extends Service implements Runnable { private Thread mThread; public int count = 0; private boolean isTip = true; private static String
Time of Update: 2018-12-03
android 調用Lua, Lua指令碼啟動Intentandroid 中的調用try {mLuaState.LdoString(readStream(getResources().openRawResource(R.raw.testLua)));// 找到functionInLuaFile函數mLuaState.getField(LuaState.LUA_GLOBALSINDEX,
Time of Update: 2018-12-03
關於 emulator-5554 disconnected! Cancelling 'xxx activity launch'!的問題,解決方案:1)、網上查詢的方法d:cd D:/Program Files/android-sdk-windows-1.6_r1/toolsemulator -avd avd1.6其中 D:/Program Files/android-sdk-windows-1.6_r1/tools是Android SDK目錄emulator -avd avd1.6啟動模擬器,
Time of Update: 2018-12-03
從網上下載的 Android Jni代碼中使用到Android Log輸出,在JNI的c檔案中如果用到了#include <utils/Log.h> 然後用NDK 編譯, ndk-build clean && ndk-build 提示error: utils/Log.h: No such file or directory如果只是用到LOG功能1 修改Android.mk檔案配置,添加如下語句LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -
Time of Update: 2018-12-03
在Android開發中,我們有需要通過“應用程式名稱”來啟動應用的需求。使用方法很簡單,Intent intent = getIntentByName("應用程式名稱");startActivity(intent);// 通過應用程式名稱,來擷取應用的 Intent 的方法 public Intent getIntentByName(String name) { PackageManager pm = getApplicationContext().
Time of Update: 2018-12-03
先看效果未擴充擴充後代碼說明AndroidManifest..xml<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.hpc.assistant" android:versionCode="1" android:versionName="1.0"
Time of Update: 2018-12-03
從這裡下載androidlua庫完整樣本工程Lua作為嵌入式指令碼語言,可以內嵌入到各種環境。下來我們來展示如何將Lua嵌入到Android當中。lua : 當前最新版5.2.1http://www.lua.org/LuaJava 當前最新版, 1.1http://www.keplerproject.org/luajava/我下載Lua5.2.1, LuaJava1.1編譯無法通過。LuaJava1.1 不支援Lua5.2.1,
Time of Update: 2018-12-03
//擷取螢幕大小,以合理設定 按鈕 大小及位置 DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; //自訂layout組件 RelativeLayout layout = new RelativeLayout(this);
Time of Update: 2018-12-03
安裝完官方說明的的包,還會出錯。編譯 一次需要74+分鐘,提示資訊host SharedLib: lib64EGL_translator (out/host/linux-x86/obj/lib/lib64EGL_translator.so)/usr/bin/ld: cannot find -lGLcollect2: ld returned 1 exit statusmake: *** [out/host/linux-x86/obj/lib/lib64EGL_translator.so]
Time of Update: 2018-12-03
以前在C/C++ 開發中,我們可以宏定義,Debug模式下,輸出日誌,方便測試。Release模式下,無日誌輸出。使用Java時,Java 是解釋語言,無法編譯。就無模式之分了。有沒有辦法實現,Debug、Release版?debug 輸出日誌、調試資訊。release 發布版本,無輸出日誌、調試資訊。辦法是人想出來的。下面說說我的解決方案:1 類比C宏定義。package cn.eben.hpc.define;public final class BuildConfig {
Time of Update: 2018-12-03
WebView 開啟帶Frameset Tag的Html檔案時,經常顯示不全,只顯示最後一個頁面。需要簡單設定之後就可以了覆蓋shouldOverrideUrlLoading, 並返回false;mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
Time of Update: 2018-12-03
android 1.5以後添加了軟體虛擬鍵盤的功能,所以在輸入提示中將會有對應的軟鍵盤模式android中inputType屬性在EditText輸入值時啟動的虛擬鍵盤的風格有著重要的作用。這也大大的方便的操作。有時需要虛擬鍵盤只為字元或只為數字。所以inputType尤為重要。<EditText android:layout_width="fill_parent" android:layout_height="wrap_content"android:inputType="phone"