safe04

1.<LinearLayout android:visibility="invisible"
  LinearLayout.setVisibility(View.INVISIBLE);

2.ListView的数据,屏幕显示多少条item,数据适配器baseAdapter就的getView方法就调用多少次。
  getView方法中的 convertView对象的作用 就是一个已经被系统回收的历史缓存的view对象。

3.ListView标签 中 android:fastScrollEnabled="true" 当快速滚动屏幕的时候,会出来一个小标签,然后可以按住这个标签快速的拖动。

4.listview 的优化.
1. 为了减少对象的创建 定义一个static 静态变量.
2. 为了提升getview方法执行的效率 减少了layoutinflate的方法执行的次数(复用了历史缓存的view对象,convertview);
3. 减少了findviewbyid()执行的次数,把id的引用 采用setTag()的方法设置到view对象里面. getTag();

5.RadioGroup标签,RadioGroup的的getCheckedRadioButtonId()方法,获取RadioGroup单选组中的每一个RadioButton的id

6.当数据适配器的内容发生改变后,通知数据适配器,更新界面里显示的内容 adapter.notifyDataSetChanged();

7.Contextual Menus:上下文菜单, 长按的时候会出来上下文菜单
1.为ListView或GridView注册一个上下文环境。registerForContextMenu(view对象);
2.实现onCreateContextMenu()方法
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}
3.实现onContextItemSelected()方法
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
     case R.id.edit:
editNote(info.id); //info.id 也就是listview里弹出来上下文菜单的 item的id
return true;
     case R.id.delete:
deleteNote(info.id);
return true;
    }
}


8.ListView 的 getItemAtPosition(position); 获取 listview中 指定位置上的 对象

9.删除一条通话记录
public void deleteCallLog(String incomingNumber) {
//Uri callLogUri = Uri.parse("content://call_log/calls");
Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, new String[]{"_id"}, "number=?", new String[]{incomingNumber}, null);
while (cursor.moveToNext()) {
String id = cursor.getString(0);
getContentResolver().delete(CallLog.Calls.CONTENT_URI, "_id=?", new String[]{id});
}
}

10.挂断电话对应的方法
public void endcall() {
try {
Method method = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
IBinder binder = (IBinder) method.invoke(null, new Object[]{TELEPHONY_SERVICE});
ITelephony telphone = ITelephony.Stub.asInterface(binder);
telphone.endCall();
} catch (Exception e) {
e.printStackTrace();
}
}

11.停止监听电话的状态
TelephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);

12.注册一个数据库内容变化的观察者
getContentResolver().registerContentObserver(uri, true, new ContentObserver());
   注册了一个观察者后,一旦数据库内容发生变化,会调用观察者里面的onChange()方法,
   注销该观察者:
getContentResolver().unregisterContentObserver(this);

13.如果activity配置了启动模式 是singleTop的模式
   当activity栈顶 与要被激活的activity相同
   就不会创建新的activity, 而是复用activity的onNewIntent();

14. PendingIntent.FLAG_UPDATE_CURRENT 指定开启的activity自动更新内容
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

15.拒收黑名单的短信,就是写一个短信的广播接受者,判断收到的短信的号码是不是黑名单中的号码,或者短信的内容是否包括拒收的关键字
是的话,abortBroadcastReceiver();

16.拒绝显示黑名单中的来电电话,注册一个service,用来监听呼叫电话的号码,

猜你喜欢

转载自xpchou.iteye.com/blog/1637545