今天把SDK从revision 11升级至了最新的revision 12,却发现出现了问题。模拟器无法运行,在运行时提示:
invalid command-line parameter: SDK\tools/emulator-arm.exe. Hint: use '@foo' to launch a virtual device named 'foo'. please use -help for more information
也就是说似乎是由于参数错误导致无法启动模拟器。
在网上还看到了有人出现这样的错误信息:
invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe. Hint: use '@foo' to launch a virtual device named 'foo'. please use -help for more information
经过一番折腾之后终于找到了问题所在。应该是路径的问题。路径参数之前还有内容,被忽略了。这应该是本次升级的一个Bug。SDK所在文件夹的名称中如果有空格就会导致问题的发生(我使用的是android SDK这一名称)。于是将文件夹重命名为android-SDK之后,问题解决。或者在eclipse-window-preference-android-sdk location 中 Program Files 改为 PROGRA~1
我采用了后一种,因为不想再安装一遍了。不过管用的。
最直接到办法时重启后重命名!
ScrollView是一个滚动条控件,当屏幕中内容很多时候需要使用滚动条。ScrollView类的继承图如下:
java.lang.Object
↳android.view.View
↳android.view.ViewGroup
↳android.widget.FrameLayout
↳android.widget.ScrollView
android.widget.ScrollView继承了android.widget.FrameLayout框架布局类。ScrollView例子如图7-9所示滚动条例子。
图7-9 Scrollview
布局文件请参考代码清单7-10,完整代码请参考chapter7_1工程中scrollview_1.xml代码部分(chapter7_1/res/layout/scrollview_1.xml)。
【代码清单7-10】
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:textSize="20dip" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/content" /> </LinearLayout> </ScrollView>
ScrollView有很多属性管理它的样式,如果在xml中设置,可以在<ScrollView >标签内设置滚动条样式的属性:
• android:scrollbars="none",不显示滚动条,但能够滚动的;
• android:scrollbarSize,滚动条大小。
修改上面的例子添加这些属性xml布局文件代码如下:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbarSize="12dip" android:scrollbars="none" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:textSize="20dip" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/content" /> </LinearLayout> </ScrollView>
出自《Android开发案例驱动教程》第七章
在Objective-c中,当一个类需要引用另一个类,即建立复合关系的时候,需要在类的头文件中建立被引用类的指针。 如:
Car.h
1
2
3
4
5
6
7
8
9
#import
@interface Car:NSObject
{
Tire *tires[4];
Engine *engine;
}
...
实现类我们先省略,如果你直接这么编译,编译器会报错,告诉你它不知道Tire和Engine是什么。
这时候有两个选择,一个是import这两个被引用类的头文件,另一个是使用@class声明Tire和Engine是类名。 二者的区别在于:
所以,一般来说,@class是放在interface中的,只是为了在interface中引用这个类,把这个类作为一个类型来用的。 在实现这个接口的实现类中,如果需要引用这个类的实体变量或者方法之类的,还是需要import在@class中声明的类进来.
如:
a.h
1
2
3
4
@class Rectangle;
@interface A : NSObject {
...
}
a.m
1
2
3
#import Rectangle
@implementation A
...