java 讀文件 http://www.cnblogs.com/lovebread/archive/2009/11/23/1609122.htmlhtml
java 寫文件 http://www.jb51.net/article/47062.htmjava
while(true) { // Read from the InputStream try { if( (bytes = mmInStream.read(buffer)) > 0 ) { resultbuffer.append(new String(buffer,0,bytes)); } if(resultbuffer.length() == 32) { String s = resultbuffer.toString(); LogUtil.i(TAG,s); Message msg = new Message(); msg.obj = s; msg.what = 2; LinkDetectedHandler.sendMessage(msg); break; } } catch (IOException e) { // TODO Auto-generated catch block //若是在已鏈接的狀況下,血壓計忽然關閉,會致使讀不到數據 e.printStackTrace(); Message msg = new Message(); msg.obj = "鏈接異常!正在重連..."; msg.what = 1; LinkDetectedHandler.sendMessage(msg); break; }
多線程 http://blog.csdn.net/michellehsiao/article/details/7639788android
字符串拼接:http://developer.51cto.com/art/201306/400370.htmcanvas
什麼是Workerman http://www.workerman.net/ Workerman是一款純PHP開發的開源的高性能的PHP socket 服務器框架。已經被多家公司用於移動通信、手遊服務端、網絡遊戲服務器、聊天室服務器、硬件通信服務器、智能家居等服務端的開發。 只要會PHP,你就能夠基於Workerman垂手可得的開發出你想要的網絡應用,沒必要再爲PHP Socket底層開發而煩惱。服務器
不能忽視的hierarchy viewer網絡
http://www.shangxueba.com/jingyan/113092.html多線程
Inflate的奇怪問題,在作桌面時,allapp一直顯示不了,問題出在this參數上app
LayoutInflater.from(context).inflate(R.layout.apps_customize_pane, this);框架
http://www.cnblogs.com/HighFun/p/3281674.htmlssh
權限出錯解決方案:
<uses-permission android:name="android.permission.BIND_APPWIDGET" /> int appWidgetId = mAppWidgetHost.allocateAppWidgetId() ; Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, mAppWidgetProviderInfo.provider); startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
callback應用失敗: http://www.jb51.net/article/61002.htm callback更新UI時要跑在主線程裏面
輸入流轉化成字符串:
resultbuffer = new StringBuffer(); byte[] buffer = new byte[1024]; int bytes; InputStream mmInStream = null; try { if( (bytes = mmInStream.read(buffer)) > 0 ) { resultbuffer.append(new String(buffer,0,bytes)); } } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); }
if視狀況改爲while
點擊二態的標準寫法:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_focused="true" android:drawable="@drawable/adduser_btn_pressed1"/> <item android:state_pressed="true" android:drawable="@drawable/adduser_btn_pressed1"/> <item android:drawable="@drawable/adduser_btn_nor1"/> </selector>
另一種寫法:
selector_common_btn.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_focused="true"> <shape > <corners android:radius="8dp"/> <solid android:color="#ff33b5e5"/> </shape> </item> <item android:state_pressed="true"> <shape > <corners android:radius="8dp"/> <solid android:color="#ff33b5e5"/> </shape> </item> <item > <shape > <corners android:radius="8dp"/> <solid android:color="#FF4ebcd3"/> </shape> </item> </selector>
引用:
<Button android:id="@+id/loadBtn" android:textColor="#FFFFFFFF" android:textSize="20sp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:padding="5dp" android:background="@drawable/selector_common_btn" android:text="登陸" />
效果:
圓形控件:
package com.toyoung.ge.customwidge; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.ImageView; /** * Created by yeran on 2015/5/18. * * 圓形ImageView控件 */ public class CustomRoundView extends ImageView { Paint paint; public CustomRoundView(Context context) { super(context); } public CustomRoundView(Context paramContext, AttributeSet paramAttributeSet) { super(paramContext, paramAttributeSet); } public CustomRoundView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { super(paramContext, paramAttributeSet, paramInt); } protected void onDraw(Canvas canvas){ Drawable drawable = getDrawable(); if(drawable==null) return; if(getWidth()==0||getHeight()==0) return; Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap(); Bitmap bitmap1 = bitmap.copy(Bitmap.Config.ARGB_8888, true); int w = getWidth(),h=getHeight(); RoundConnerBitmap rb = new RoundConnerBitmap(); canvas.drawBitmap(rb.toRoundBitmap(bitmap1,w), 0, 0, null); } }