常见问题参考合辑

java 读文件 http://www.cnblogs.com/lovebread/archive/2009/11/23/1609122.html

java 写文件 http://www.jb51.net/article/47062.htm

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;
                    }
View Code

 

多线程 http://blog.csdn.net/michellehsiao/article/details/7639788

字符串拼接:http://developer.51cto.com/art/201306/400370.htm

Linux学习之CentOS(十四)--初识ssh

什么是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参数上

 LayoutInflater.from(context).inflate(R.layout.apps_customize_pane, this);

http://www.cnblogs.com/HighFun/p/3281674.html

权限出错解决方案:

 

<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时要跑在主线程里面

 

Android Context 上下文 你必须知道的一切

 

输入流转化成字符串:

           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);
    }


}

 

posted @ 2015-04-02 21:11  疾风剑  阅读(249)  评论(0编辑  收藏  举报