2013-1224

说明:FlowLayoutPanel里边放入Label,对Label拖拽实现排序。


1.给Label注册MouseDown事件:

label.MouseDown += new System.Windows.Forms.MouseEventHandler(Label_MouseDown);


响应Label鼠标按下事件内容:11

private void Label_MouseDown(object sender, MouseEventArgs e)
{                 阅读全文>>
                
标签: FlowLayoutPanel Drag and Drop 拖拽排序 阅读:19939
2013-1125

xml中的textView:

<TextView
        android:id="@+id/bookTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:drawableLeft="@drawable/checkmark"
        android:gravity="center_vertical"
        android:textStyle="bold"
        android:textSize="24dip" 阅读全文>>
                
标签: Android TextView DrawableLeft 阅读:9850
2013-1119

在Android的布局文件中,往往使用dp作为控件的宽度和高度尺寸,但是在Java代码中,调用getWidth()方法获得的尺寸单位却是像素px,这两个单位有明显的区别:dp和屏幕的密度有关,而px与屏幕密度无关,所以使用时经常会涉及到两者之间的互相转化,代码示例如下:

public int Dp2Px(Context context, float dp) {
    final float scale = context.getResources().getDisplayMetrics().density;
 阅读全文>>

标签: Android px2dp dp2px 阅读:9292
2013-1105

查了下资料发现setTextColor()的参数应该写成以下的这种形式:


setTextColor(0xFF0000FF);//0xFF0000FF是int类型的数据,分组一下0x|FF|0000FF,0x是代表颜色整数的标记,ff是表示透明度,0000FF表示颜色.


注意:这里0xFF0000FF必须是8个的颜色表示,不接受0000FF这种6个的颜色表示。



另外还可以使用系统自带的颜色类

setTextColor(android.graphics.Co 阅读全文>>

标签: Android setTextColor TextView 阅读:13406
2013-1011

异常信息 org.json.JSONException: Value  of type java.lang.String cannot be converted to JSONObject

在2.3以上版本不出错,2.3的时候报这个问题,搜索得到:


由于utf-8的bom头引起的,让去掉bom头,但是也没解决了,即使在本地进行处理json字符串将bom头去掉,但是也不行。json字符串格式也没问题,所以可以肯定的是json字符内部有无法识别或者未知的字符,所以当时就把当时得到的json字符串进... 阅读全文>>

标签: Android JSONException JSONObject 阅读:11063
2013-0924

Android在绑定服务的时候出现java.lang.ClassCastException:android.os.BinderProxy cannot be cast to com.

修改manifest文件里边相关服务去掉android:process=":remote"即可。

标签: Android BinderProxy ClassCastException 阅读:14620
2013-0916

IllegalStateException: Can't deserialize target data of key 'IdeaAndroidProject'. Given class loaders: [PluginClassLoader[org.jetbrains.android, 10.0]]: Can't deserialize target data of key 'IdeaAndroidProject'. Given class loaders: [PluginClassLoader[org.jetbrains.android, 10.0]]


报这个错误,新建工程也看不到源文件,升级新版本可以解决这个问题

 阅读全文>>

标签: IllegalStateException Android Studio Update 离线升级 阅读:11678
2013-0502

首先FilterConfig添加

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    filters.Add(new CustomHandleErrorAttribute());
}


自定义HandleErrorAttribute如下:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true) 阅读全文>>
                
标签: HandleErrorAttribute MVC4 CustomHandleErrorAttribute 阅读:20302