没有合适的资源?快使用搜索试试~ 我知道了~
Android-Widgets-Spinners
需积分: 0 1 下载量 37 浏览量
2015-08-01
15:45:47
上传
评论
收藏 1.15MB PDF 举报
温馨提示
试读
17页
Android-Widgets-Spinners
资源推荐
资源详情
资源评论
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Widgets: Spinners
(Combo Boxes)
Originals of Slides and Source Code for Examples:
http://www.coreservlets.com/android-tutorial/
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
For live Android training, please see courses
at http://courses.coreservlets.com/.
Taught by the author of Core Servlets and JSP, More
Servlets and JSP, and this Android tutorial. Available at
public venues, or customized versions can be held
on-site at your organization.
• Courses developed and taught by Marty Hall
– JSF 2, PrimeFaces, servlets/JSP, Ajax, jQuery, Android development, Java 6 or 7 programming, custom mix of topics
– Ajax courses can concentrate on 1 library (jQuery, Prototype/Scriptaculous, Ext-JS, Dojo, etc.) or survey several
• Courses developed and taught by coreservlets.com experts (edited by Marty)
– Spring, Hibernate/JPA, EJB3, GWT, Hadoop, SOAP-based and RESTful Web Services
Contact hall@coreservlets.com for details
Topics in This Section
• Switching from one Activity to another
• Spinners with choices set in XML
• Spinners with choices set in Java
6
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
General Approach
for Widget Examples
Widget Lectures Combined in
Single Project
• Main screen
– Lets user choose screens on various Widget topics
• Other screens
– Correspond to separate lectures.
• One screen for lecture on Buttons, another for lecture on
Spinners, another for number input, etc.
• Separate layout files
– main.xml, buttons.xml, spinners.xml, etc. See next slide.
• Separate Java classes
– WidgetActivity.java, ButtonActivity.java,
SpinnerActivity.java, etc.
• Shared strings file
– strings.xml has separate sections for each lecture, but same file
8
Layout Files for Widget Lectures
• Separate layout files for each Activity
– res/layout/main.xml
• Gives layout for main screen. Loaded with
setContentView(R.layout.main);
– res/layout/buttons.xml
• Gives layout for screen on Button and related Widgets.
Loaded with setContentView(R.layout.buttons);
– res/layout/spinners.xml
• Gives layout for screen on Spinners (i.e., combo boxes).
Loaded with setContentView(R.layout.spinners);
• Two common layout attributes
– android:layout_width, android:layout_height
• match_parent (fill up space in enclosing View)
• wrap_content (use natural size)
9
Strings File for Widget Lectures
(res/values/strings.xml)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Initial screen -->
<string name="app_name">...</string>
<string name="show_buttons_button_label">...</string>
<string name="show_spinners_button_label">...</string>
<!-- Buttons example -->
<!-- Shown in earlier lecture -->
<!-- Spinners example -->
<!-- Shown in this lecture -->
...
</resources>
10
Switching Activities: Summary
• Switches Activities with Intents
– Main screen has buttons to navigate to other Activities
– Return to original screen with phone’s “back” button
• Syntax required to start new Activity
– Java
• Intent newActivity = new Intent(this, NewActivity.class);
• startActivity(newActivity);
– XML
• Requires entry in AndroidManifest.xml (which is part of
downloadable Eclipse project for Widgets)
– More details
• Code shown on next few slides
• Even more information given in later lecture on Intents
11
剩余16页未读,继续阅读
资源评论
jerome_wang
- 粉丝: 4
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功