_Android Tips

Tags:

If you’re still getting “out of memory” you should do something like that:

  1.  
  2. BitmapFactory.Options options=new BitmapFactory.Options();
  3. options.inSampleSize = 8;
  4. Bitmap preview_bitmap=BitmapFactory.decodeStream(is,null,options);
  5.  

This inSampleSize option reduces memory usage.

  1.  
  2. BitmapFactory.Options options = new BitmapFactory.Options();
  3. options.inTempStorage = new byte[16*1024];
  4. bitmapImage = BitmapFactory.decodeFile(path,opt);
  5.  

_Android开发之callback后改变UI会报错

Tags: , , , , ,

发现是自己AsyncTask用错了!!doInBackground后返回的result是给onPostExecute调用的,这两个方法都要重写,执行到onPostExecute后就是回到主线程去执行了..也就没有底下的问题了

———————————————-

只有创建UI的线程才能修改这个UI,假设你用的是实现接口的方式做callback的话,必须在callback的类里做一个Handler对象来接收callback里的sendMessage.
另外android的表单验证是Activity实现一个TextWatcher,在afterTextChange事件后作验证;当然,要把每个EditText的addTextChangedListener指向本类(这些EditText属于这个类),另外,如果出错要设置EditText.setError的话,也要在Handler里用sendMessage的方式来做.

_android折腾记录

Tags:

指定android的SDK HOME目录,不然会提示你找不到AVD(默认生成到用户目录下)
环境变量里设置ANDROID_SDK_HOME=D:\Program Files\android-sdk-windows 另外VISTA底下需要修改.android/avd底下的形如AVD_API1.5.ini配置文件里面的路径