2016年3月9日Android实习日记

1.

解决 org.eclipse.swt.SWTException: Graphic is disposed 问题。

参考:http://www.xuebuyuan.com/1896964.html

2.成员变量String str ,默认为null ;只生成一个string类型的引用;不分配内存空间

一个变量作为类成员使用的时候,如果没有被初始化,java会为其分配默认值:
Boolean false
Char '\u0000'(null)
byte (byte)0
short (short)0
int 0
long 0L
float 0.0f
double 0.0d
如果在一个方法中定义一个变量,java不会给其分配默认值,就必须我们来给他初始化,否则将得到编译错误的提示;
参考:http://zhidao.baidu.com/link?url=7ppW5x_aX_-WuegFmmCfOrCHsU7DoCDxjiG1si6uF0yK5fbSD2vaoOQ-0CUxOGNvm6a1a1nmNaZ4CezZ17_Bzq
参考:http://bdcwl.blog.163.com/blog/static/7652226520091022114215737/

3.RadioGroup的指定选项设置颜色。

RadioButton radioButton = (RadioButton) (radioGroup.getChildAt(id));
radioButton.setTextColor(0xFF7AC5CD);

((RadioButton) (radioGroup.getChildAt(answer))).setTextColor(0xFF66CDAA);

setTextColor(0xFF0000FF);//0xFF0000FF是int类型的数据,分组一下0x|FF|0000FF,0x是代表颜色整数的标记,ff是表示透明度,0000FF表示颜色,注意:这里0xFF0000FF必须是8个的颜色表示,不接受0000FF这种6个的颜色表示。

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

setTextColor(android.graphics.Color.BLUE);

或setTextColor(this.getResources().getColor(R.color.blue));//通过获得资源文件进行设置。

参考:http://blog.csdn.net/chiuan/article/details/7058686

测试代码/*String temp = String.valueOf(checkedId);
Toast.makeText(ExamDetial.this, temp, 200).show();*/

显示代码中的public void onCheckedChanged(RadioGroup group, int checkedId) {}

checkedId为很长的一串数字,表示为:the unique identifier of the newly checked radio button。

4.程序延时一段时间,然后执行接下来的任务。

new Handler().postDelayed(new Runnable(){
public void run() {
//execute the task
}
}, delay);
参考:http://blog.csdn.net/qinde025/article/details/6828723

5.

padding:1px2px3px4px;
margin:5px6px7px8px;
分别表示什么位置呢?

1px2px3px4px的位置顺序是上右下左

6.

若是Eclipse将视图的屏幕切换到5.1寸的,就可以看到很长的布局了。参考:http://zhidao.baidu.com/link?url=6i5rP8esQfAiUIPuLP9kokG4_rFeZCTLpfoTP6Innu26cVGw4f9mkYjgTJrHhegXEv7_DGCJPS7nqzs5pTdxkVwUqQ94FXP-899SR-SF7M3

7.ScrollView,只能容纳一个直接的子控件,我们可以间接的容纳多个子控件,直接在这些子控件外面再套一层LinearLayout就可以了。我自己解决了,并且之后找到了一篇与我想法一样的。

参考:http://www.2cto.com/kf/201205/131877.html

8.设置行距,android:lineSpacingExtra="3dp" 。参考:http://blog.csdn.net/az44yao/article/details/7852353

9.ScrollView与我加的手势操作冲突,原因是系统原生的控件ScrollView的左右滑动事件的onInterceptTouchEvent返回true拦截了事件,所以需要重写该事件让其返回false,让左右滑动事件传递到手势操作中去。

ScrollView的重写参考:http://zwnjava.iteye.com/blog/1698749

10.Toast重复显示的解决办法。参考:http://blog.csdn.net/mddy2001/article/details/7836696

 

posted @ 2016-03-09 09:35  龙杉老师  阅读(1589)  评论(0编辑  收藏  举报