零碎知识总结

1、Activity.findViewById(int id)与View.findViewById(int id)的区别?

Activity.findViewById(int id)表示通过在xml文件中的id属性来查找控件

Finds a view that was identified by the id attribute from the XML that was processed in onCreate

View.findViewById(int id)表示在给定View上查找id为给定id值得控件

Look for a child view with the given id. If this view has the given id, return this view.


2、View.inflate的参数解释

  1. /*int resource,也就是resource/layout文件在R文件中对应的ID,这个必须指定。
  2. 而ViewGroup root则可以是null,null时就只创建一个resource对应的View,不是null时,会将创建的view自动加为root的child
  3. */
  4. View inflate(int resource, ViewGroup root)

3、反编译

工具:

4、startActivity(Intent intent)与startActivityForResult(Intent  intent)的区别
startActivity(Intent intent)是上下文的方法
startActivityForResult(intent, requestCode)是Activity的方法

5、判断字符串是否为空或长度为0

TextUtils.equals(String str);


6、在服务里面打开一个Activity需要设置标记,给指定的Activity添加任务栈。不然会报错
  1. Intent intent = new Intent(WatchDogService.this,passWord_Activity.class);
  2. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  3. intent.putExtra("PackName",packName);
  4. startActivity(intent);

Activity的属性

7、让最近打开的Activity不在最近列表显示
  1. android:excludeFromRecents="true"
8、Activity在新的任务栈显示
  1. android:launchMode="singleInstance"

9、手机杀毒原理

10、获得手机的型号、版本、
  1. //获取手机型号和系统版本号
  2. String sdk=android.os.Build.VERSION.SDK; // SDK号
  3. String model=android.os.Build.MODEL; // 手机型号
  4. String release=android.os.Build.VERSION.RELEASE; // android系统版本号

11、ListView的加载

listView的加载过程,是数据加载完了,才呈现在手机屏幕上,如果想让用户看到加载过程逐条呈现可以使用其他的布局方式


12、openFileOutput的意义

例:拷贝数据库文件:assets->data/data/com.itheima.mobilesafe/files

  1. InputStream is = getAssets().open(dbname); //打开程序包中的资产文件
  2. FileOutputStream fos = this.openFileOutput(dbname, Context.MODE_PRIVATE);//对应的路径data/data/com.itheima.mobilesafe/files

13、进度条progressBar的基本用法

  1. 在xml文件中默认样式为原型如果想改为长条型可以添加属性 style="?android:attr/progressBarStyleHorizontal"
    

  1. //控制prograssBar的进度
  2. progressBar1.setMax(packInfos.size());//设置总大小
  3. progressBar1.setProgress(progress);//设置当前进度

14、让控件的点击属性失效
  1. //设置为不可用点击
  2. view.getChildAt(i).setEnabled(false);

15、ViewGroup的一些特点

viewgroup可以获得父控件上的子控件,但View没有这个能力


16、layout_width=-2 表示包裹内容




posted @ 2015-02-06 21:21  就不呵呵呵  阅读(174)  评论(0编辑  收藏  举报