【翻译】(51)data元素
see
http://developer.android.com/guide/topics/manifest/data-element.html
原文见
http://developer.android.com/guide/topics/manifest/data-element.html
-------------------------------
<data>
data元素
-------------------------------
* syntax:
* 语法:
-------------------------------
<data android:host="string"
android:mimeType="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:port="string"
android:scheme="string" />
-------------------------------
* contained in:
* 被包含在:
<intent-filter>
* description:
* 描述:
Adds a data specification to an intent filter. The specification can be just a data type (the mimeType attribute), just a URI, or both a data type and a URI. A URI is specified by separate attributes for each of its parts:
添加一个数据规范到一个意图过滤器。规范可以只是一个数据类型(mimeType属性),只是一个URI,或者一个数据类型和一个URI都有。一个URI被不同的属性对它的每个部分作指定。
scheme://host:port/path or pathPrefix or pathPattern
<模式>://<主机>:<端口>/<路径>或<路径前缀>或<路径模式>
These attributes are optional, but also mutually dependent: If a scheme is not specified for the intent filter, all the other URI attributes are ignored. If a host is not specified for the filter, the port attribute and all the path attributes are ignored.
这些属性是可选的,但也是相互依赖的:如果没有为意图过滤器指定一个scheme,那么其它所有URI属性被忽略。如果没有为意图过滤器指定一个host,那么port属性和所有path属性被忽略。
All the <data> elements contained within the same <intent-filter> element contribute to the same filter. So, for example, the following filter specification,
在相同的<intent-filter>元素中包含的所有<data>元素作用于相同的过滤器。因此,例如以下过滤器规范,
-------------------------------
<intent-filter . . . >
<data android:scheme="something" android:host="project.example.com" />
. . .
</intent-filter>
-------------------------------
is equivalent to this one:
等价于这个:
-------------------------------
<intent-filter . . . >
<data android:scheme="something" />
<data android:host="project.example.com" />
. . .
</intent-filter>
-------------------------------
You can place any number of <data> elements inside an <intent-filter> to give it multiple data options. None of its attributes have default values.
你可以放置任意数量的<data>元素在一个<intent-filter>中以给它多个数据选项。它的没有属性有默认值。
Information on how intent filters work, including the rules for how Intent objects are matched against filters, can be found in another document, Intents and Intent Filters. See also the Intent Filters section in the introduction.
关于意图过滤器如何工作的信息,包括Intent对象如何匹配过滤器的规则,可以在另一个文档意图与意图过滤器中找到。另见介绍中的意图过滤器章节。
* attributes:
* 属性:
* android:host
The host part of a URI authority. This attribute is meaningless unless a scheme attribute is also specified for the filter.
URI权力的主机部分。这个属性是没有意义的除非为该过滤器指定一个scheme属性。
-------------------------------
Note: host name matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should always specify host names using lowercase letters.
注意:在Android框架中主机名称匹配是大小写敏感的,不像正式的RFC(注:Request For Comments,用于制订基本的互联网通讯协定)那样,你应该总是使用小写字母指定主机名称。
-------------------------------
* android:mimeType
A MIME media type, such as image/jpeg or audio/mpeg4-generic. The subtype can be the asterisk wildcard (*) to indicate that any subtype matches.
一个MIME(注:Multipurpose Internet Mail Extensions,多功能互联网邮件扩展)媒体类型,诸如image/jpeg或audio/mpeg4-generic。子类型可以是星号通配符(*)以指示匹配任意子类型。
-------------------------------
Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types. As a result, you should always specify MIME types using lowercase letters.
注意:在Android框架中MIME类型匹配是大小写敏感的,不像正式的RFC MIME类型那样。因此,你应该总是用小写字母指定MIME类型。
-------------------------------
* android:path
* android:pathPrefix
* android:pathPattern
The path part of a URI. The path attribute specifies a complete path that is matched against the complete path in an Intent object. The pathPrefix attribute specifies a partial path that is matched against only the initial part of the path in the Intent object. The pathPattern attribute specifies a complete path that is matched against the complete path in the Intent object, but it can contain the following wildcards:
URI的路径部分。path属性指定一个完整的路径,它被匹配到一个Intent对象中的完整路径。pathPrefix属性指定一个局部路径,它只是被匹配到Intent对象的路径的开始部分。pathPattern属性指定一个完整路径,它被匹配到Intent对象中的完整路径,但它可以包含以下通配符:
* An asterisk ('*') matches a sequence of 0 to many occurrences of the immediately preceding character.
* 一个星号('*')匹配一个零到多次出现的即时(注:紧接)前驱字符的序列。
* A period followed by an asterisk (".*") matches any sequence of 0 to many characters.
* 一个点后面跟着一个星号(".*")匹配0到多个字符的任意序列。
Because '\' is used as an escape character when the string is read from XML (before it is parsed as a pattern), you will need to double-escape: For example, a literal '*' would be written as "\\*" and a literal '\' would be written as "\\\\". This is basically the same as what you would need to write if constructing the string in Java code.
因为'\'被用作一个转义字符当该字符串从XML中被读取(在它被解释为一个模式之前),你将需要双转义:例如,一个字面'*'应该被写成"\\*"而一个字面'\'应该被写成"\\\\"。这基本上和如果在Java代码中构造字符串的话你需要写的东西是相同的。
For more information on these three types of patterns, see the descriptions of PATTERN_LITERAL, PATTERN_PREFIX, and PATTERN_SIMPLE_GLOB in the PatternMatcher class.
想获得关于这三种类型模式的更多信息,参见PatternMatcher类中PATTERN_LITERAL,PATTERN_PREFIX,和PATTERN_SIMPLE_GLOB的描述。
These attributes are meaningful only if the scheme and host attributes are also specified for the filter.
这些属性是有意义的仅当还为该过滤器指定scheme和host属性。
* android:port
The port part of a URI authority. This attribute is meaningful only if the scheme and host attributes are also specified for the filter.
URI权力的端口部分。这个属性有意义仅当还为该过滤器指定scheme和host属性。
* android:scheme
The scheme part of a URI. This is the minimal essential attribute for specifying a URI; at least one scheme attribute must be set for the filter, or none of the other URI attributes are meaningful.
一个URI的模式部分。它是指定一个URI的最小基本属性;必须为该过滤器设置至少一个scheme属性,否则其它URI属性中没有一个是有意义的。
A scheme is specified without the trailing colon (for example, http, rather than http:).
一个模式被指定不带结束的冒号(例如,http,而非http:)
If the filter has a data type set (the mimeType attribute) but no scheme, the content: and file: schemes are assumed.
如果过滤器拥有一个数据类型集合(mimeType属性)但没有模式,那么假定是content:和file:模式。
-------------------------------
Note: scheme matching in the Android framework is case-sensitive, unlike the RFC. As a result, you should always specify schemes using lowercase letters.
注意:在Android框架中模式匹配是大小写敏感的,不像RFC那样。因此,你应该总是使用小写字母指定模式。
-------------------------------
* introduced in:
* 引入:
API Level 1
API级别1
* see also:
* 另见:
<action>
<category>
Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.
除特别说明外,本文在Apache 2.0下许可。细节和限制请参考内容许可证。
Android 4.0 r1 - 10 Feb 2012 0:44
-------------------------------
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
(此页部分内容基于Android开源项目,以及使用根据创作公共2.5来源许可证描述的条款进行修改)
(本人翻译质量欠佳,请以官方最新内容为准,或者参考其它翻译版本:
* ソフトウェア技術ドキュメントを勝手に翻訳
http://www.techdoctranslator.com/android
* Ley's Blog
http://leybreeze.com/blog/
* 农民伯伯
http://www.cnblogs.com/over140/
* Android中文翻译组
http://androidbox.sinaapp.com/
)
点击图片即可下载O(∩_∩)O哈!
[wp7游戏]水果忍者/切水果(汉化版) 1.1
[wp7游戏]涂鸦跳跃(芒果) 1.3
[wp7游戏]砖石迷情(芒果) 1.1
[wp7游戏]青蛙过河 1.0
[wp7游戏]愤怒的小鸟 1.0.0.0
[wp7游戏]花匠汉化版 1.0
[wp7游戏]航空指挥官 1.2
[wp7游戏]蝴蝶飞 1.0
[wp7游戏]齿轮大转盘 1.0
[wp7游戏]城市油漆工 1.0
[wp7游戏]吃豆人 1.2
[wp7游戏]燃烧殆尽 1.0
[wp7游戏]叠楼方块之纽约 1.0
[wp7游戏]猴子岛闯关mango版 1.3
[wp7游戏]跳梁小丑 1.0
[wp7游戏]魔法水滴 1.1
[wp7游戏]吃豆人冠军版 1.0
[wp7游戏]3D打砖块 1.0
[wp7游戏]月球着陆器 1.0
[wp7游戏]莎莉的美发沙龙 1.2.0.0
[wp7游戏]愤怒的小鸟(汉化版) 1.5.3
[wp7游戏]离子球增强版 1.1
[wp7游戏]逻辑游戏三合一 1.0
[wp7游戏]光辉工匠 1.1
[wp7游戏]XBL数独 1.1
[wp7游戏]XBL扫雷 1.1
[wp7游戏]钻头姥爷Mango优化版 1.1
[wp7游戏]花阵 1.2
[wp7游戏]重力小子 1.1
[wp7游戏]块魂 1.1
[wp7游戏]脑力训练 1.0
footview的模版如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:gravity="center_horizontal" android:padding="3dp" android:layout_height="fill_parent"> <TextView android:id="@id/android:empty" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" android:padding="5dp" android:text="Loading more days..."/> </LinearLayout> [代码] 然后记得在加到adapter前,把footview加到listview中去 View footerView = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listfooter, null, false); this.getListView().addFooterView(footerView); this.setListAdapter(adapter); [代码] listview的onscroll方法如下 this.getListView().setOnScrollListener(new OnScrollListener(){ public void onScrollStateChanged(AbsListView view, int scrollState) {} public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int lastInScreen = firstVisibleItem + visibleItemCount; String last=Integer.toString(lastInScreen); Log.d("show",last); String total=Integer.toString(totalItemCount); Log.d("total",total); if((lastInScreen == totalItemCount) && !(loadingMore)){ Thread thread = new Thread(null, loadMoreListItems); thread.start(); } } }); Thread thread = new Thread(null, loadMoreListItems); thread.start(); /** 下面来分析下,其中,可以预先设置一个屏的listview能显示多少条记录,比如设置为5条, 这里itemsPerPage=15,然后首先 int lastInScreen = firstVisibleItem + visibleItemCount; 这里,获得每屏中最后一条数据的位置,比如一次先显示5条,则lastInScreen=5了, */ if((lastInScreen == totalItemCount) && !(loadingMore)){ Thread thread = new Thread(null, loadMoreListItems); thread.start(); } /** 这里是判断,如果是滚动了滚动条,并且用户以及功能浏览完了一次屏幕所需要的数目(比如5个),则启用线程序loadMoreListItems去处理,加载另外的新的5个了. 而如果没滚动,则第一次显示时,也要启用线程序loadMoreListItems去处理. . 下面看loadMoreListItems. */ private Runnable loadMoreListItems = new Runnable() { public void run() { loadingMore = true; myListItems = new ArrayList<String>(); //Simulate a delay, delete this on a production environment! try { Thread.sleep(1000); } catch (InterruptedException e) {} //Get 15 new listitems for (int i = 0; i < itemsPerPage; i++) { myListItems.add("Date: " + (d.get(Calendar.MONTH)+ 1) + "/" + d.get(Calendar.DATE) + "/" + d.get(Calendar.YEAR) ); d.add(Calendar.DATE, 1); } runOnUiThread(returnRes); } }; /** 在这个线程里,实际上就是用循环往listview中加日期,产生从当天时间起的若干个日期格式,然后调用 runOnUiThread(returnRes);去更新UI主线程,注意 runOnUiThread是 android提供的方法,可以帮助你在线程中执行UI更新操作. 在更新主线程中,十分简单,只不过往adapter中去增加元素,并且notifyDataSetChanged通知listview起变化了, 并设置loadingMore=false,因为已经加载完了一次了. */