ObjectiveC Property

Alt none

ref: Cocoa Programming for Mac OS X p94

XLIFF 在 Android 中的简单应用

XLIFF(XML Localization Interchange File Format): XML本地化数据交换格式。

string.xml

<resources xmlns:xliff="urn.oasis:names:tc:xliff:document:1.2">

    <string name="person"><xliff:g id="name">%1$10s</xliff:g> <xliff:g id="age">%2$s</xliff:g></string>

</resources>

JAVA

String person = getString(R.string.person, "lnmcc", 90);

参数格式说明

id: 属性名 %n$m[s,d,f]: n参数索引;m对齐方式或数据精度;[s,d,f]接受的数据类型

Android Framework 配置需要默认编译APK

build/target/product/core.mk

Objc中的 Selector与函数指针

定义

函数指针

int func(int arg) {

}

int (*pfunc)(int);
pfunc = func;

Selector

@interface cls
-(int) func : int arg
@end

SEL SFunc;
SFunc = @Selector(func:int);

调用

函数指针

pfunc(1);

Selector

cls *obj = [[cls alloc]init];
[obj performSelector : SFunc withObject : 1];

Android 多窗口分屏(原生方法)

事实上KitKat已经可以实现多窗口分屏,只是功能不全,Google并没有把这个功能提供给用户。

使用am stack boxes可以查看当前系统存在的Activity Stack:

am stack boxes

output:

Box id=1 weight=0.0 vertical=false bounds=[0,38][800,1208]
Stack=
  Stack id=1 bounds=[0,38][800,1208]
    taskId=2: com.android.calendar/com.android.calendar.AllInOneActivity
    taskId=3: com.android.deskclock/com.android.deskclock.DeskClock

Box id=0 weight=0.0 vertical=false bounds=[0,38][800,1208]
Stack=
  Stack id=0 bounds=[0,38][800,1208]
    taskId=1: net.lnmcc.launcher/net.lnmcc.launcher.Launcher

从上面的输出我们看到当前有两个Stack,id分别为0和1。在Stack 1中存在了两个Task,这两个Task分别是Calender和DeskClock应用。而Launcher则是在Stack 0中。实际上,你会发现Launcher始终独占Stack 0。Android有如下规则:

  • HOME stack: This is the stack with id = 0. This stack is used by the Launcher activities. When several users run Lanchers on one device, they will all belong to this stack. Other than that, systemui activities are also launched in it.
  • Applications stack: The id for this stack could be any number. All activities that are neither Launcher apps or systemui activities are run here (for all users).

得到了上面关于Stack和Task的信息后就可以按需要使用am stack create来进行分屏显示了:

am stack create 2 1 4 0.5

效果图如下(上半屏为日历应用,下半屏为时钟应用):

Alt none 使用上面的命令你可以控制两个APP的相对位置,各自的大小等等。。。具体参数说明如下:

再次运行am stack boxes来查看一下究竟发生了什么:

am stack boxes

output:

Box id=1 weight=0.5 vertical=true bounds=[0,38][800,1208]
First child=
  Box id=2 weight=0.0 vertical=false bounds=[0,38][800,623]
  Stack=
    Stack id=2 bounds=[0,38][800,623]
      taskId=2: com.android.calendar/com.android.calendar.AllInOneActivity
Second child=
  Box id=3 weight=0.0 vertical=false bounds=[0,623][800,1208]
  Stack=
    Stack id=1 bounds=[0,623][800,1208]
      taskId=3: com.android.deskclock/com.android.deskclock.DeskClock

Box id=0 weight=0.0 vertical=false bounds=[0,38][800,1208]
Stack=
  Stack id=0 bounds=[0,38][800,1208]
    taskId=1: net.lnmcc.launcher/net.lnmcc.launcher.Launcher

我们看到Box 1中有了2个子Box,分别用来存放Calendar和DeskClock,并且bounds的值给出了他们各自的显示区域坐标。