編輯:關於Android編程
本文在不斷更新中。。。。
1.字符串比較
我在獲取EditText中的內容時,初始時得到的是"",然後我直接判斷edittextString=="",結果怎麼都跳入,記得MFC中比較好像可以直接這樣,然後改為edittextString.equals("")正確。
[java]
if(!tmpString.equals(""))
{
tmpString+="/";
}
if(!tmpString.equals(""))
{
tmpString+="/";
}2.string操作
和MFC中CString類一樣有很多方法,其中我比較喜歡的是split分割字符串,這個在CString中貌似沒有,但是string沒有find(有indexof可以實現)。(詳細見點此)
3.int與string轉換
4.組件的操作
android中組件的操作都是通過id來實現的(findViewById()),對於一組組件的操作,我首先想到,id是int型的,那我直接對於id可以數學操作,得到我想要的id,然後findViewById(),例如
[java]
id=0x7f050000+timeInt*7+weekInt;
textView=(TextView)findViewById(id);
id=0x7f050000+timeInt*7+weekInt;
textView=(TextView)findViewById(id);但是發現這樣並不好(移植性等)
然後發現可以定義一個id的int型數組,例如
[java]
int[] weeks=new int[]{
R.id.week1,
R.id.week2,
R.id.week3,
R.id.week4,
R.id.week5,
R.id.week6,
R.id.week7,
R.id.week8,
R.id.week9,
R.id.week10,
R.id.week11,
R.id.week12,
R.id.week13,
R.id.week14,
R.id.week15,
R.id.week16,
R.id.week17,
R.id.week18,
R.id.week19,
R.id.week20
};
int[] weeks=new int[]{
R.id.week1,
R.id.week2,
R.id.week3,
R.id.week4,
R.id.week5,
R.id.week6,
R.id.week7,
R.id.week8,
R.id.week9,
R.id.week10,
R.id.week11,
R.id.week12,
R.id.week13,
R.id.week14,
R.id.week15,
R.id.week16,
R.id.week17,
R.id.week18,
R.id.week19,
R.id.week20
};這樣操作起來,和數組序號對應以來,操作很方便,
[java]
for(int i=0;i<weeks.length;i++)
{
checkBox=(CheckBox)findViewById(weeks[i]);
checkBox.setChecked(false);
}
for(int i=0;i<weeks.length;i++)
{
checkBox=(CheckBox)findViewById(weeks[i]);
checkBox.setChecked(false);
}5.數據庫操作
6.布局
游戲中攝像頭的原理介紹 在游戲開發中更新攝像頭的位置可以決定屏幕顯示的內容,尤其是RPG類游戲攝像頭有著非常重要的作用,我
Summary:SDK, ADB, Active, Intents and Tasks-The Android SDK is made of mostly off-the
最近整理出android-獲取網絡時間、獲取特定時區時間、時間同步的方法。具體如下:方法一:SimpleDateFormat dff = new SimpleDateFo
android開發中實現單選與多選對話框的代碼非常簡單,具體代碼如下所示:public void myClick(View view) { // 單選對話框 //si