編輯:關於Android編程
復制代碼 代碼如下:
package com.homer.phone;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class phoneRead extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
showListView();
}
private void showListView(){
ListView listView = new ListView(this);
ArrayList<HashMap<String, String>> list = getPeopleInPhone2();
SimpleAdapter adapter = new SimpleAdapter(
this,
list,
android.R.layout.simple_list_item_2,
new String[] {"peopleName", "phoneNum"},
new int[]{android.R.id.text1, android.R.id.text2}
);
listView.setAdapter(adapter);
setContentView(listView);
}
private ArrayList<HashMap<String, String>> getPeopleInPhone2(){
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); // 獲取手機聯系人
while (cursor.moveToNext()) {
HashMap<String, String> map = new HashMap<String, String>();
int indexPeopleName = cursor.getColumnIndex(Phone.DISPLAY_NAME); // people name
int indexPhoneNum = cursor.getColumnIndex(Phone.NUMBER); // phone number
String strPeopleName = cursor.getString(indexPeopleName);
String strPhoneNum = cursor.getString(indexPhoneNum);
map.put("peopleName", strPeopleName);
map.put("phoneNum", strPhoneNum);
list.add(map);
}
if(!cursor.isClosed()){
cursor.close();
cursor = null;
}
return list;
}
}
記得在AndroidManifest.xml中加入android.permission.READ_CONTACTS這個permission
復制代碼 代碼如下:
<uses-permission android:name="android.permission.READ_CONTACTS" />
在使用App的時候,首次登錄都需要用戶輸入密碼的,有些朋友為了安全起見密碼設置的比較長,導致很多次密碼都輸入錯誤,嚴重影響了用戶體驗效果。這一點移動開發者做好了准備工作,
首先弄懂怎麼設置adb wifi無線調試的功能,如下所示。1. 手機端開啟adb tcp連接端口:/$setprop service.adb.tcp.port 5555:
效果圖直接在xml文件中添加即可,在代碼中調用setProgress(int) 即可。代碼注釋寫的很清楚,有興趣的隨便改改。InstrumentView.javapack
實現效果如下:實現思路:1、如何實現圓中水面上漲效果:利用Paint的setXfermode屬性為PorterDuff.Mode.SRC_IN畫出進度所在的矩形與圓的交集