sqlite中用boolean類(lèi)型保存的數(shù)據(jù),因?yàn)閏ursor沒(méi)有g(shù)etBoolean()方法,取出時(shí)可用先用cursor.getInt()方法來(lái)取,若是true則為1,否則為0,然后再轉(zhuǎn)換為boolean類(lèi)型的數(shù)據(jù)
<pre>
</pre>-
錯(cuò)誤
</pre>
<pre>
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.getapninfo/com.example.getapninfo.ApnDetailActivity}:
android.content.res.Resources$NotFoundException: String resource ID #0x1
無(wú)標(biāo)題.png
出錯(cuò)位置:
<pre>((TextView) findViewById(R.id.title_id_show)).setText(apn.getId());
</pre>出錯(cuò)原因:
一般發(fā)生在參數(shù) int resId 錯(cuò)誤,你把String賦值給int的resId,所以編譯器找不到正確的resource于是報(bào)錯(cuò)。
其中apn.getId()返回Int類(lèi)型,setText()又有幾種重載,參數(shù)類(lèi)型各不相同,所以傳入錯(cuò)誤的參數(shù)類(lèi)型會(huì)報(bào)錯(cuò)。
應(yīng)改為:<pre>
((TextView) findViewById(R.id.title_id_show)).setText(""+apn.getId());
</pre> 如果要在DDMS中查看手機(jī)的文件,有的文件需要root之后才能查看
adb root連續(xù)按兩次BACK鍵退出
private long firstTime = 0;
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
switch(keyCode)
{
case KeyEvent.KEYCODE_BACK:
long secondTime = System.currentTimeMillis();
if (secondTime - firstTime > 2000) { //如果兩次按鍵時(shí)間間隔大于2秒,則不退出
Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
firstTime = secondTime;//更新firstTime
return true;
} else { //兩次按鍵小于2秒時(shí),退出應(yīng)用
System.exit(0);
}
break;
}
return super.onKeyUp(keyCode, event);
}
- 隱藏輸入法
方法一:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); //得到InputMethodManager的實(shí)例
if (imm.isActive()) {
//如果開(kāi)啟imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
//關(guān)閉軟鍵盤(pán),開(kāi)啟方法相同,這個(gè)方法是切換開(kāi)啟與關(guān)閉狀態(tài)的}
方法二:在onclick事件下.以下方法可行.(如果是EditText失去焦點(diǎn)/得到焦點(diǎn),沒(méi)有效果)
InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(getCurrentFocus().getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
-
可拖拽排序的listview
-
將其他工程添加為library
選中將要被當(dāng)做library的項(xiàng)目,右擊選擇Properties,選擇Android,拉到最下面
給Is Library前面的checkbox打上勾,點(diǎn)擊Apply,OK
然后,右擊需要library的項(xiàng)目,同樣Properties里面,拉到最后,點(diǎn)擊Add,將上一個(gè)項(xiàng)目添加進(jìn)來(lái)
會(huì)發(fā)現(xiàn)在該項(xiàng)目Android Dependencies這個(gè)library下會(huì)多出一個(gè)jar包,這樣就能識(shí)別了

