|
在manifest的activity節(jié)點使用
<activity android:windowSoftInputMode="adjustResize" . . . >
當點擊EditText控件彈出軟鍵盤的時候,系統(tǒng)會自動調整控件的位置。
代碼
http://github.com/shaobin0604/miscandroidapps/tree/master/WindowSoftInputMode/
參考
AppWidget的初始化有兩種方式:
目前遇到的問題是:
在Launcher里可以預先配置桌面顯示的AppWidget,如果AppWidget有Configure Activity,則系統(tǒng)在AppWidget的初始化過程不會發(fā)送android.appwidget.action.APPWIDGET_CONFIGURE Intent,而只是加載appwidget-provider里配置的initialLayout。這樣第二種就不可用,只能用第一種方法。
synchronized void
setTextSize(WebSettings.TextSize t)
Set the text size of the page.
void
setSupportZoom(boolean support)
Set whether the WebView supports zoom
void
setInitialScale(int scaleInPercent)
Set the initial scale for the WebView.
boolean
zoomIn()
Perform zoom in in the webview
boolean
zoomOut()
Perform zoom out in the webview
void
setBuiltInZoomControls(boolean enabled)
Sets whether the zoom mechanism built into WebView is used.
synchronized void
setJavaScriptEnabled(boolean flag)
Tell the WebView to enable javascript execution.
在程序里備份恢復數(shù)據(jù)
public static boolean backupDatabase() {
File dbFile = new File(Environment.getDataDirectory() + "/data/" + PKG + "/databases/" + DB_NAME);
File exportDir = new File(Environment.getExternalStorageDirectory(), "pocket-voa");
if (!exportDir.exists()) {
exportDir.mkdirs();
}
File file = new File(exportDir, dbFile.getName());
try {
file.createNewFile();
copyFile(dbFile, file);
return true;
} catch (IOException e) {
Log.e(TAG, "[backupDatabase] error", e);
return false;
}
}
public static boolean restoreDatabase() {
File dbFile = new File(Environment.getDataDirectory() + "/data/" + PKG + "/databases/" + DatabaseHelper.DB_NAME);
File exportDbFile = new File(Environment.getExternalStorageDirectory() + "/pocket-voa/" + DatabaseHelper.DB_NAME);
if (!exportDbFile.exists())
return false;
try {
dbFile.createNewFile();
copyFile(exportDbFile, dbFile);
return true;
} catch (IOException e) {
Log.e(TAG, "[restoreDatabase] error", e);
return false;
}
}
private static void copyFile(File src, File dst) throws IOException {
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} finally {
if (inChannel != null)
inChannel.close();
if (outChannel != null)
outChannel.close();
}
}
參考
There are certain events that Android does not want to start up new processes for, so the device does not get too slow from all sorts of stuff all having to run at once.
ACTION_SCREEN_ON
is one of those. See this previous question for light blue advice on that topic.
So, you need to ask yourself, "Self, do I really need to get control on those events?". The core Android team would like it if your answer was "no".
打開終端輸入
adb devices
出現(xiàn)如下內容
??????????? no permissions
原因是啟動adb的時候需要有root權限。如果一開始忘記加了sudo, 就必須先終止adb。
$ adb kill-server
$ sudo adb start-server
$ adb devices
就可以看到設備信息了。
Ubuntu 9.10 64bit, sun-jdk-1.5(因需要編譯Android源代碼), Android SDK 2.1
draw9patch 不能正確顯示出窗口,沒有菜單欄
sun jdk 1.5 的BUG
安裝 sun jdk 1.6
sudo apt-get install sun-java6-jdk
sudo update-alternatives –config java