cur.moveToFirst();<br style="word-wrap:break-word;">
do {<br style="word-wrap:break-word;">
int nameColumn = cur.getColumnIndex(People.NAME);<br style="word-wrap:break-word;">
int phoneColumn = cur.getColumnIndex(People.NUMBER);<br style="word-wrap:break-word;">
String name = cur.getString(nameColumn);<br style="word-wrap:break-word;">
String phoneNumber = cur.getString(phoneColumn);<br style="word-wrap:break-word;">
Toast.makeText(this,name,Toast.LENGTH_LONG).show();<br style="word-wrap:break-word;">
Toast.makeText(this,phoneNumber,Toast.LENGTH_LONG).show();<br style="word-wrap:break-word;">
} while (cur.moveToNext());<br style="word-wrap:break-word;">
<br style="word-wrap:break-word;">
107 android 创建WebView<br style="word-wrap:break-word;">
WebView webView = new WebView(this);<br style="word-wrap:break-word;">
webView.loadData("&lt;html&gt;"+"&lt;head&gt;test&lt;/head&gt;"+"&lt;body&gt;test&lt;/body&gt;"+"&lt;/html&gt;", "text/html", "utf-8");<br style="word-wrap:break-word;">
108 android 设置地图是否显示卫星和街道<br style="word-wrap:break-word;">
mapView.setSatellite(false);&nbsp;<br style="word-wrap:break-word;">
mapView.setStreetView(true);<br style="word-wrap:break-word;">
109 android 单选框清除<br style="word-wrap:break-word;">
radioGroup.clearCheck();<br style="word-wrap:break-word;">
110 android 给文本增加链接<br style="word-wrap:break-word;">
Linkify.addLinks(mTextView01,Linkify.WEB_URLS);<br style="word-wrap:break-word;">
Linkify.addLinks(mTextView02,Linkify.EMAIL_ADDRESSES);<br style="word-wrap:break-word;">
Linkify.addLinks(mTextView03,Linkify.PHONE_NUMBERS);<br style="word-wrap:break-word;">
111 android 设置手机震动<br style="word-wrap:break-word;">
Vibrator vibrator = (Vibrator)getApplication().getSystemService(Service.VIBRATOR_SERVICE);<br style="word-wrap:break-word;">
vibrator.vibrate( new long[]{1000,1000,1000,1000},-1);//震动一秒,停一秒,再震一秒<br style="word-wrap:break-word;">
112 android 创建下拉框<br style="word-wrap:break-word;">
Spinner spinner = new Spinner(this);<br style="word-wrap:break-word;">
113 android 给spinner添加事件<br style="word-wrap:break-word;">
spinner.setOnItemSelectedListener(<br style="word-wrap:break-word;">
new Spinner.OnItemSelectedListener()<br style="word-wrap:break-word;">
&nbsp; &nbsp; {<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;public void onItemSelected(AdapterView&lt;?&gt; parent,View view,int position,long id)<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;{<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;}<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;public void onNothingSelected(AdapterView&lt;?&gt; parent)<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;{<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;}<br style="word-wrap:break-word;">
&nbsp; &nbsp; });<br style="word-wrap:break-word;">
114 android 图片的显示方式<br style="word-wrap:break-word;">
ImageView imageView = new ImageView(this);<br style="word-wrap:break-word;">
imageView.setScaleType(ImageView.ScaleType.FIT_XY);//适应大小<br style="word-wrap:break-word;">
imageView.setScaleType(ImageView.ScaleType.CENTER);//原始大小,居中显示<br style="word-wrap:break-word;">
115 android 取得缓存目录<br style="word-wrap:break-word;">
File cacheDir = this.getCacheDir();<br style="word-wrap:break-word;">
116 android 取得当前文件目录<br style="word-wrap:break-word;">
File fileDir = this.getFilesDir();<br style="word-wrap:break-word;">
117 android 判断当前wifi是否可用<br style="word-wrap:break-word;">
WifiManager aWiFiManager = (WifiManager)<br style="word-wrap:break-word;">
this.getSystemService(Context.WIFI_SERVICE);<br style="word-wrap:break-word;">
boolean isEnabled = aWiFiManager .isWifiEnabled);<br style="word-wrap:break-word;">
118 android 判断当前wifi是否已经打开<br style="word-wrap:break-word;">
WifiManager aWiFiManager = (WifiManager)<br style="word-wrap:break-word;">
this.getSystemService(Context.WIFI_SERVICE);<br style="word-wrap:break-word;">
if(aWiFiManager.getWifiState()==WifiManager.WIFI_STATE_ENABLED)<br style="word-wrap:break-word;">
Log.i("TEST","it is open");<br style="word-wrap:break-word;">
119 android 判断SIM卡状态<br style="word-wrap:break-word;">
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);<br style="word-wrap:break-word;">
if(telephonyManager.getSimState()==telephonyManager.SIM_STATE_READY)<br style="word-wrap:break-word;">
&nbsp; &nbsp; {<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;Log.i("TEST","正常");<br style="word-wrap:break-word;">
&nbsp; &nbsp; }<br style="word-wrap:break-word;">
&nbsp; &nbsp; else if(telephonyManager.getSimState()==telephonyManager.SIM_STATE_ABSENT)<br style="word-wrap:break-word;">
&nbsp; &nbsp; {<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;Log.i("TEST","无SIM卡");<br style="word-wrap:break-word;">
&nbsp; &nbsp; }<br style="word-wrap:break-word;">
120 android 取得SIM卡商名称<br style="word-wrap:break-word;">
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);<br style="word-wrap:break-word;">
String name = telephonyManager.getSimOperatorName();<br style="word-wrap:break-word;">
121 android 为activity增加键盘事件<br style="word-wrap:break-word;">
public boolean onKeyDown(int keyCode, KeyEvent event)<br style="word-wrap:break-word;">
{<br style="word-wrap:break-word;">
switch(keyCode)<br style="word-wrap:break-word;">
{<br style="word-wrap:break-word;">
case KeyEvent.KEYCODE_DPAD_UP:<br style="word-wrap:break-word;">
&nbsp;&nbsp;Log.i("上",String.valueOf(keyCode));<br style="word-wrap:break-word;">
&nbsp;&nbsp;break;<br style="word-wrap:break-word;">
case KeyEvent.KEYCODE_DPAD_DOWN:<br style="word-wrap:break-word;">
&nbsp;&nbsp;Log.i("下",String.valueOf(keyCode));<br style="word-wrap:break-word;">
&nbsp;&nbsp;break;<br style="word-wrap:break-word;">
case KeyEvent.KEYCODE_DPAD_LEFT:<br style="word-wrap:break-word;">
&nbsp;&nbsp;Log.i("左",String.valueOf(keyCode));<br style="word-wrap:break-word;">
&nbsp;&nbsp;break;<br style="word-wrap:break-word;">
case KeyEvent.KEYCODE_DPAD_RIGHT:<br style="word-wrap:break-word;">
&nbsp;&nbsp;Log.i("右",String.valueOf(keyCode));<br style="word-wrap:break-word;">
&nbsp;&nbsp;break;<br style="word-wrap:break-word;">

Prev | Next
Pg.: 1 2 3 4 5 6 7 8 9 10 11 12


Back to home | File page

Subscribe | Register | Login | N