android 随笔

1.file.deleteOnExist();

2.android.intent.action.MEDIA_EJECT 在设置界面点击卸载sd卡弹出提示消息时会发出该intent.

  android.intent.action.MEDIA_UNMOUNTED 点击确定后发出action这个的intent. 
 
  android.intent.action.MEDIA_UNMOUNTED  拔出sd卡的时候还是会发出为这个的广播意图.

  android.intent.action.MEDIA_REMOVED 拔出的时候也会发出action为这个的广播意图.

  android.intent.action.MEDIA_UNMOUNTED 刚插入sd卡的时候会发出该广播意图.

  android.intent.action.MEDIA_MOUNTED 然后是这个广播意图.

3. ①、没看API,就查了下网上的资料,原来requestWindowFeature 是用来设置全屏的。

       在Activity中

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);  设置无标题

        getWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

                 WindowManager.LayoutParams.FLAG_FULLSCREEN);  设置无状态栏,两者即为全屏.

②、<activity 
    android:name=".MyActivityClassName" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />  xml中实现activity的全屏


intent = new Intent(SzSelectSongActivity.this,SongListActivity.class);
getResources() 是context的方法
intent.putExtra("title", getResources().getString(titleParameter)

android:configChanges="keyboardHidden|orientation

4.  注册和使用BroadCast传递消息

public static final String BROADCAST_FOR_PIC="BROADCAST_FOR_PIC";//定义filteraction
//定义

public BroadcastReceiver mBr = new BroadcastReceiver() {

@Override
public void onReceive(Context arg0, Intent arg1) {
adapter.notifyDataSetChanged();
Log.d(tag,"notifyDataSetChanged");
}

};
//取消注册
@Override
    protected void onPause() {
    this.unregisterReceiver(mBr);
   
        super.onPause();
    }

//注册

@Override
    protected void onResume() {[size=medium][/size]
IntentFilter filter = new IntentFilter();
filter.addAction(BROADCAST_FOR_PIC);
this.registerReceiver(mBr, filter);
      
if(adapter!=null){
adapter.notifyDataSetChanged();
}

super.onResume();
    }

//点击删除后,发送broadcast
Intent it = new Intent();
it.setAction(StoreListActivity.BROADCAST_FOR_STORE_PIC);
context.sendBroadcast(it);

5. 关于数据库查询 BaseColumns 类。

6.int width = (0 + image0.getRight() - image0.getLeft()) / 2;  View 的中心位置.

7.strings 文件可以这样写:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, MainActivity!</string>
    <string name="app_name">看论语测试</string>
    <bool name="ceshizheshi">false</bool>
</resources>

通过这样去访问  boolean b =

                    getContext().getResources().getBoolean(R.bool.ceshizheshi);

你可能感兴趣的:(android,xml)