1.Shader


http://www.cnblogs.com/snake-hand/archive/2012/02/17/2454392.html


2.SparseArray 替代 HashMap 针对<interger object>

http://liuzhichao.com/p/832.html

3.onCLick

if (System.currentTimeMillis() - mLastClickTime < 300) {      // in order to avoid user click bottom too quickly      return;  }    if (!button.isEnabled())      return;    mLastClickTime = System.currentTimeMillis();  mLastButtonId = button.getId(); 

这样写,在一般场景下会更严谨,防止一些重复点击之类的操作,可以根据自己的情况,在进行添加.

4.TextView跑马灯

android:ellipsize="marquee"  android:marqueeRepeatLimit="marquee_forever"  android:singleLine="true"  

这个跑马灯需要在获取焦点的时候才能有效果.

不获取焦点也有跑马灯效果.

自定义一个TextView,它继承TextView,并且重写isFocuse()方法,让它永远返回true.


5.SlidingDrawer 点击事件传递到下面布局的问题.

今天看到一个,在使用了SlidingDrawer ,open状态下,仍然能触发抽屉覆盖的View点击事件.

解决办法.在content 添加android:clickable="true" 属性. 猜测应该是因为 默认的content没有任何事件,就传递到下面.


6.Android 4.0 HttpURLConnection 下载失败问题

http://blog.csdn.net/mmmlllii/article/details/8000081


7.View高度获取

在OnCreate()方法中获取控件的高度和宽度,需要使用的一个观察者(否则得到的height, paddingTop等数据为0,因onCreate()执行时,控件还未加载完成)

ViewTreeObserver vto = imageview.getViewTreeObserver();        vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {            @Override            public void onGlobalLayout() {                // 此句若不执行,不影响控件宽高的获取结果,但是当前的onGlobalLayout()会执行多次,执行此句,当前方法只会执行一次                imageview.getViewTreeObserver().removeGlobalOnLayoutListener(                        this);                Log.i("TAG", imageview.getMeasuredHeight()                        + " -- - " + imageview.getHeight());            }        });

8.页面跳转动画android:minSdkVersion="8"

Intent intent = new Intent(TransitionActivity.this, DeviceActivity.class);                startActivity(intent);                finish();                //页面切换 -- 淡入淡出效果                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

9.设置汉字粗体

TextView title = new TextView(context);TextPaint paint = title.getPaint();paint.setFakeBoldText(true); 

10.Eclipse 调用 compatibility 不能创建新项目


之前一直用的是MotoDev开发,没有遇到类似的问题.有次帮同事搭建新环境,安装了Eclipse,创建新项目时,就会出现这个问题. 提示的是我缺少android-compatibility 文件.

但其实我是已经下载过的.

点击文档查看一下.文档这一段,在想想自己的下载目录,知道了吧.

When done, all files (including source code, samples, and the.jarfiles) are saved into the<sdk>/extras/android/support/directory. This directory contains each of the different support libraries, such as the library for API level 4 and up and the library for API level 13 and up, each named with the respective version (such asv4/).

我们只需要把 ~/android-compatibility 下的文件复制到 ~/extras/android/support/ 下,再Check 就好了.

11. 4.0,访问网络不能在主程序中进行

http://geeksun.iteye.com/blog/1447708

12.Dialog宽度设置.

在做项目中,有时候会遇到Dialog不受控制的问题.可以通过以下代码实现. 但是有个问题就是不够灵活.
WindowManager m = getWindowManager();              Display d = m.getDefaultDisplay();  //为获取屏幕宽、高                        LayoutParams p = getWindow().getAttributes();  //获取对话框当前的参数值       Point outSize = new Point();  d.getSize(outSize);    Log.i(TAG, outSize.x + "-" + outSize.y);  p.width = (int) (outSize.x * 0.6);      p.alpha = 1.0f;            p.dimAmount = 0.7f;    p.gravity = Gravity.CENTER;  getWindow().setAttributes(p);   

13.Android 4.0 HttpURLConnection 下载失败问题

URL u = new URL(url);  HttpURLConnection c = (HttpURLConnection) u.openConnection();  c.setRequestMethod("GET");  c.setDoOutput(true);  c.connect();  (new File(FileUtils.getCachePath())).mkdirs();  FileOutputStream f = new FileOutputStream(new File(file));  InputStream in = c.getInputStream();  
之前一直使用的这套代码做下载部分的实现.但是今天主管告诉我应用在4.0上出现问题. 查看代码后发现是图片下载失败的问题.
在4.0 上 c.getInputStream();会报 java.io.FileNotFoundException. 解决办法是注释掉c.setDoOutput(true);.

http://comments.gmane.org/gmane.comp.handhelds.android.devel/195330

14.Android 4.0 WebView loadData 加载中文乱码

之前使用过loadData这种方式加载Html代码段.今天写一个功能需要使用,但是在我的手机(4.04)上却出现了中文乱码.无论如何设置编码,都无法发解决. baidu一下,解决办法是 使用loadDataWithBaseURL. 解释:点击打开链接
15.Android ListView 点击后刷新. <item name="android:choiceMode">singleChoice</item> 这个标识ListView 为单选的属性.今天在开发的时候,发现点击完后,总会引发item里的图片再次刷新. 刚开始以为是Adapter的问题... 找了半天,去掉这个属性就好了.

16.Webview--让加载进来的页面自适应手机屏幕分辨率居中显示.

让Webview加载的页面居中显示有我知道的俩种方法

第一种:

[java]
WebSettings settings = webView.getSettings();
settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
LayoutAlgorithm是一个枚举用来控制页面的布局,有三个类型:

1.NARROW_COLUMNS:可能的话使所有列的宽度不超过屏幕宽度

2.NORMAL:正常显示不做任何渲染

3.SINGLE_COLUMN:把所有内容放大webview等宽的一列中

用SINGLE_COLUMN类型可以设置页面居中显示,页面可以放大缩小,但这种方法不怎么好,有时候会让你的页面布局走样而且我测了一下,只能显示中间那一块,超出屏幕的部分都不能显示。

第二种方法:

[java]
//设置加载进来的页面自适应手机屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
第一个方法设置webview推荐使用的窗口,设置为true。第二个方法是设置webview加载的页面的模式,也设置为true。

这方法可以让你的页面适应手机屏幕的分辨率,完整的显示在屏幕上,可以放大缩小。
推荐使用第二张方法


更多相关文章

  1. android value 42 报错
  2. Android的字符编码转换问题,Unicode,GB2312,UTF8等
  3. Android之自定义标题栏(组合控件)
  4. android 6.0权限问题处理的核心代码--shouldShowRequestPermissi
  5. Android(安卓)Fresco的使用
  6. android 页面跳转(intent)
  7. Android(安卓)studio配置NDK问题小结
  8. Android中关于EditText不能取得值的问题解决方案
  9. Android(安卓)java.lang.IllegalArgumentException: You cannot

随机推荐

  1. 什么是线程池?
  2. Java 中的锁如何使用?有什么注意事项?
  3. 并行是什么意思?与并发的区别是什么?
  4. Executors如何创建线程池?
  5. 什么是线程?什么是进程?为什么要有线程?有什
  6. Java 中锁之间的对比
  7. Java 中线程池包含哪些状态?
  8. 首申百度联盟、Google Adsense,均败
  9. synchronized 锁的升级原理是什么?
  10. 博客网站显示框相对浏览器固定位置显示