android开发笔记(二)导入项目到eclipse和另一个项目

时间:2023-03-10 03:30:54
android开发笔记(二)导入项目到eclipse和另一个项目

NND,eclipse里导入工程出现问题了,整了半天,来个这问题,无效工程描述,找了半天看.projec文件是否工程名对应,看androidManifest.XML换里面的代码版本号,我擦都无济于事。

无意中发现importing project的时候会出来个android下的Existing android code into workspace,千万别选这个,选了的话搞什么换目录等,烦死你。

最轻松的解决办法是:往上面看,还有个general里,这个文件夹下有个Existing projects into workspace,选择这个才行。

有些时候在做涉及一些关于android系统安全的项目时,如更改手机的状态等

会添加一些权限,
此时eclipse会提示错误:
Permission is only granted to system apps
(权限仅授予系统应用)
此时只需要clean项目,因为所用权限涉及系统安全.如果手机没有root状态,此项目会报错崩溃.
被root手机运行正常.
引入其他工程
按如下方法设置:
1. 假设要引用的android工程叫LibProject,引入到的工程叫MainProject;
2. 设置LibProject,右键-Properties-Android,将Is library项选中,然后Apply;
3. 设置MainProject,右键--Properties-Android, 在Library中,点击Add按钮,将LibProject工程加入,Apply即可。
设置完成后,在MainProject工程中能看到LibProject的代码等资源都已经引入进来。
控件在最上层显示的方法 view.bringToFront() 可以讲布局在下层的控件放到上层,不被其他控件挡住。
可以用相对布局RelativeLayout;然后给他一个id;然后再写那个按钮时把他相对的父控件式这个相对布局的id;下面是按钮总在最上层的右下角:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webMainLayout"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnRegister"
android:layout_alignBottom="@id/webMainLayout"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="切换邮箱" />
</RelativeLayout>
运行的时候总是有这个报错,E/Trace﹕ error opening trace file: No such file or directory (2),但应用正常运行了,其实这个是android api 的版本和模拟器(或者测试手机)的版本不一致导致的,设置成一样的就没问题了。