NSString 转换成NSData 对象
NSData* xmlData = [@"testdata" dataUsingEncoding:NSUTF8StringEncoding];
NSData 转换成NSString对象
NSData * data;
NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSData 转换成char*
NSData *data;
char *test=[data bytes];
char* 转换成NSData对象
byte* tempData = malloc(sizeof(byte)*16);
NSData *content=[NSData dataWithBytes:tempData length:16];
-----------------
英文文档见android-ndk-r5b的documentation.html
属于Android Native Development Kit (NDK)的一部分
见http://developer.android.com/sdk/ndk/(需要代理)
翻译仅个人见解
-----------------
Android NDK Installation
Android NDK安装
Introduction:
介绍:
-------------
Please read docs/OVERVIEW.html to understand what the Android NDK is and is not. This file gives instructions on how to properly setup your NDK.
请阅读docs/OVERVIEW.html以理解Android NDK是什么和不是什么。这个文件给出关于如何合理地配置你的NDK的步骤。
I. Requirements:
一、系统需要:
----------------
The Android NDK currently requires a Linux, OS X or Windows host operating system.
Android NDK当前需要一个Linux、OS X或Windows主机操作系统。
Windows users will need to install Cygwin 1.7 or later (http://www.cygwin.com) to use the NDK. Note that running it under MSys or Cygwin 1.5 is not supported.
Windows用户将需要安装Cygwin 1.7或更新(http://www.cygwin.com)以使用NDK。注意不支持在MSys或Cygwin 1.5下运行它。
You will need to have the Android SDK and its dependencies installed. The NDK cannot generate final application packages (.apk files), only the shared library files that can go into them.
你将需要已经安装了Android SDK和它的依赖。NDK不能生成最终的应用程序包(.apk文件),仅仅生成可以封装进去的动态库文件。
IMPORTANT:
The Android NDK can only be used to target system images using the Cupcake (1.5) or later releases of the platform.
重要事项:
Android NDK仅可以用于使用Cupcake(1.5)或更新的平台发布版的目标镜像。
This is due to subtle toolchain and ABI related changed that make it incompatible with 1.0 and 1.1 system images.
这是因为工具链和ABI相关的微妙改变致使其不兼容1.0和1.1系统镜像。
The NDK requires GNU Make 3.81 or later being available on your development system. Earlier versions of GNU Make might work but have not been tested.
NDK需要你的开发环境可以使用GNU Make 3.81或更新。早期的GNU Make版本可能可以工作,但未测试过。
You can check this by running 'make -v' from the command-line. The output should look like:
你可以通过在命令行上运行make -v检查它。输出看起来应该像这样:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
...
On certain systems, GNU Make might be available through a different command like 'gmake' or 'gnumake'. For these systems, replace 'make' by the appropriate command when invoking the NDK build system as described in the documentation. You might also want to define the GNUMAKE environment variable to point to it.
在某些系统上,GNU Make可能通过一个不同的命令像gmake或gnumake可用。对于这些系统,正如文档中描述那样,在调用NDK构建系统时用适当的命令替换make。你还可以定义GNUMAKE变量指向它。
The NDK also requires a Nawk or GNU Awk executable being available on your development system. Note that the original 'awk' program doesn't implement the 'match' and 'substr' functions used by the NDK build system.
NDK还需要在你的开发系统上有一个可用的Nawk或GNU Awk可执行文件。注意原始的awk程序没有实现NDK构建系统使用的match和substr函数。
II. Preparing your installation prebuilt cross-toolchain binaries:
二、准备你的预构建交叉工具链二进制文件的安装:
------------------------------
Previous releases required you to run the 'build/host-setup.sh' script to configure the NDK. However, this step has been removed in release 4 (a.k.a. r4).
以前的发布版需要你运行build/host-setup.sh脚本配置NDK。然而,这个步骤已经在发布版4(即r4)被移除。
The auto-detection and sanity checks that were performed by the script have been moved into the NDK makefiles (and are now performed each time you invoke GNU Make).
执行自动检测和合理性检查的脚本已经被引入到NDK makefile(现在每当你调用GNU Make时都会执行它)。
问题一:Android中自定义ListView无法响应OnItemClickListener中的onItemClick方法问题
在Android软件设计与实现中我们通常都会使用到ListView这个控件,系统有一些预置的Adapter可以使用,例如SimpleAdapter和ArrayAdapter,但是总是会有一些情况我们需要通过自定义ListView来实现一些效果,那么在这个时候,我们通常会碰到自定义ListView无法选中整个ListViewItem的情况,也就是无法响应ListView的onItemClickListener中的onItemClick()方法,究竟是为什么呢?我之前也在网上查过不少的资料,但是没有发现什么有价值的文章,有一些是建议在Adapter的getView方法中对自己需要响应单击事件的控件进行设置。但是最终的效果并不是特别理想,而且我认为这是一种取巧的方式,并不推荐。之后自己查看了一下ViewGroup的源码,发现了以下的一段常量声明:
/** * This view will get focus before any of its descendants. */
public static final int FOCUS_BEFORE_DESCENDANTS = 0×20000;
/** * This
view will get focus only if none of its descendants want it. */
public static final int FOCUS_AFTER_DESCENDANTS = 0×40000;
/** * This
view will block any of its descendants from getting focus, even * if they
are focusable. */
public static final int FOCUS_BLOCK_DESCENDANTS = 0×60000;
我们看到了一行代码定义的变量的意思是“当前View将屏蔽他所有子控件的Focus状态,即便这些子控件是可以Focus的”,其实这段话的意思就是这个变量代表着当前的View将不顾其子控件是否可以Focus自身接管了所有的Focus,通常默认能获得focus的控件有Button,Checkable继承来的所有控件,这就意味着如果你的自定义ListViewItem中有Button或者Checkable的子类控件的话,那么默认focus是交给了子控件,而ListView的Item能被选中的基础是它能获取Focus,也就是说我们可以通过将ListView中Item中包含的所有控件的focusable属性设置为false,这样的话ListView的Item自动获得了Focus的权限,也就可以被选中了,也就会响应onItemClickListener中的onItemClick()方法,然而将ListView的Item Layout的子控件focusable属性设置为false有点繁琐,我们可以通过对Item Layout的根控件设置其android:descendantFocusability=”blocksDescendant”即可,这样Item Layout就屏蔽了所有子控件获取Focus的权限,不需要针对Item Layout中的每一个控件重新设置focusable属性了,如此就可以顺利的响应onItemClickListener中的onItenClick()方法了。