自定义控件和Android Library Project 知识链接汇总
2011-12-30 10:19
375 查看
最近在研究andorid自定义控件和分项目编写,以下链接给了我很大帮助,感谢这些乐于分享的人。不敢独享,分享一下:
1.android 自定义id
在res\values建立ids.xml文件,格式和系统一致
2.Android 中自定义控件和属性(attr.xml,declare-styleable,TypedArray)的方法和使用
3.Android 自定义View自定义属性的声明
4.创建和使用Android library工程
5.Android学习系列(6)--App模块化及工程扩展
6.android 引用外部库工程
7.Managing Projects from Eclipse with ADT 这个事官方的
8.关于Android-library自定义属性的使用简介
9.Issue 9656 Library projects don't support custom XML attributes for custom classes.
10.Help with a custom View attributes inside a Android Library Project
8-10 提供解决Android-library自定义属性的杯具
8中的
注意,上面的lfchart应用的是主工程的包名,而不是控件的包名。
这句话很有用,以下两种分案,都是围绕着它。
下面英文比较简单,我就不翻译了啊
9中的
Comment 20 by wolfram....@gmail.com, Jul
27, 2011
可以,我试过。
10中的
After two hours of work with my coworker, we figure out how to make this work : Library : com.library mywidget.java with a class MyWidget
attrs.xml :
and put your attr
Instead of having your layout (main.xml for example) with your widget declared in it, juste create a my_widget.xml in the layout foler of your library. my_widget.xml
for including it in your layout, juste put
App : com.myapp
You juste have to duplicate my_widget.xml here, and change the namespace :
And normally it will work !
可以,我试过。
Android-library真是个杯具啊,以上两种方法,都很dt。不知道有谁还有更好的解决方法,和大家分享一下。
1.android 自定义id
在res\values建立ids.xml文件,格式和系统一致
2.Android 中自定义控件和属性(attr.xml,declare-styleable,TypedArray)的方法和使用
3.Android 自定义View自定义属性的声明
4.创建和使用Android library工程
5.Android学习系列(6)--App模块化及工程扩展
6.android 引用外部库工程
7.Managing Projects from Eclipse with ADT 这个事官方的
8.关于Android-library自定义属性的使用简介
9.Issue 9656 Library projects don't support custom XML attributes for custom classes.
10.Help with a custom View attributes inside a Android Library Project
8-10 提供解决Android-library自定义属性的杯具
8中的
注意,上面的lfchart应用的是主工程的包名,而不是控件的包名。
这句话很有用,以下两种分案,都是围绕着它。
下面英文比较简单,我就不翻译了啊
9中的
Comment 20 by wolfram....@gmail.com, Jul
27, 2011
I might have just found quite a simple work-arround: Steps: 1. define a String resource in the library project with your library package: <string name="NS">http://schemas.android.com/apk/res/com.company.yourLIBRARYproject</string> 2. define the same resource for your app project with your app package: <string name="NS">http://schemas.android.com/apk/res/com.company.yourAPPproject</string> 3. replace all custom namespace definitions in library and app project with xmlns:custom="@string/NS" (instead of xmlns:custom="http://schemas.android.com/apk/res/com.company.yourLIBRARYproject" and xmlns:custom="http://schemas.android.com/apk/res/com.company.yourAPPproject" ) Attributes can now be called the normal way custom:attribute ="value"
可以,我试过。
10中的
After two hours of work with my coworker, we figure out how to make this work : Library : com.library mywidget.java with a class MyWidget
attrs.xml :
<declare-styleable name="MyWidget">
and put your attr
Instead of having your layout (main.xml for example) with your widget declared in it, juste create a my_widget.xml in the layout foler of your library. my_widget.xml
<?xml version="1.0" encoding="utf-8"?> <com.library.MyWidget xmlns:android="http://schemas.android.com/apk/res/android" xmlns:widget="http://schemas.android.com/apk/res/com.library" android:id="@+id/your_id" android:layout_width="fill_parent" android:layout_height="fill_parent" widget:your_attr> </com.library.MyWidget>
for including it in your layout, juste put
<include layout="@layout/my_widget"></include>
App : com.myapp
You juste have to duplicate my_widget.xml here, and change the namespace :
<?xml version="1.0" encoding="utf-8"?> <com.library.MyWidget xmlns:android="http://schemas.android.com/apk/res/android" xmlns:widget="http://schemas.android.com/apk/res/com.myapp" <---- VERY IMPORTANT android:id="@+id/your_id" android:layout_width="fill_parent" android:layout_height="fill_parent" widget:your_attr> </com.library.MyWidget>
And normally it will work !
可以,我试过。
Android-library真是个杯具啊,以上两种方法,都很dt。不知道有谁还有更好的解决方法,和大家分享一下。
相关文章推荐
- android知识链接汇总(2)
- android知识链接汇总(3)
- android知识链接汇总
- android 蓝牙知识链接汇总
- Android Library Project自定义控件属性无法找到说明
- android知识链接汇总
- android知识链接汇总
- Android知识链接汇总
- android知识链接汇总(5)
- Android的ContextMenu(上下文菜单)知识链接汇总
- android 广告方面知识汇总
- android通过ant打包带有Library project和第三方jar包 的脚本实现
- 苹果开发者账号(IDP)注册知识链接汇总
- Android二维码知识汇总
- android eclipse 导入工程报错unable to get system library for the project
- 解决Android 工程出现 unable to get system library for the project 异常
- 如何将win7安装到 移动硬盘/U盘 及 VHD、BCD等相关知识 链接汇总
- Android知识汇总
- Android :Your project contains error(s),please fix them before running your application.可能遇到的错误汇总
- Android项目引用2个以上library project 时的报错