android.R.layout.simple_spinner_dropdown_item和android.R.layout.simple_spinner_item到底是啥意思?
2015-10-22 14:09
337 查看
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
或
private String[] items= {"lorem", "ipsum", "dolor", "sit", "amet",….
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
spin.setAdapter(aa);
都提到了R.layout,这到底是啥?
看sdk下的sdk\platforms\android-18\data\res\layout下有很多的文件
打开simple_spinner_item.xml看看
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**
http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="inherit"/>
打开simple_spinner_dropdown_item.xml文件看看
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**
http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="?android:attr/dropdownListPreferredItemHeight"
android:ellipsize="marquee"
android:textAlignment="inherit"/>
看看android的api文档里也提到了这两个家伙
原来是使用自带的xml啊,那就可以自定义Spinner的Layout,替换掉体统默认的android.R.layout.simple_spinner_item。
请参考http://www.blogjava.net/crazycoding/archive/2011/07/09/353981.html
或
private String[] items= {"lorem", "ipsum", "dolor", "sit", "amet",….
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
spin.setAdapter(aa);
都提到了R.layout,这到底是啥?
看sdk下的sdk\platforms\android-18\data\res\layout下有很多的文件
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**
http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="inherit"/>
打开simple_spinner_dropdown_item.xml文件看看
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**
http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="?android:attr/dropdownListPreferredItemHeight"
android:ellipsize="marquee"
android:textAlignment="inherit"/>
看看android的api文档里也提到了这两个家伙
请参考http://www.blogjava.net/crazycoding/archive/2011/07/09/353981.html
相关文章推荐
- Android View.onMeasure方法的理解
- Android Color 颜色过度计算实现方法
- Android 百度地图开发(二)
- android反编译
- Android 操作系统的内存回收机制
- android listview 属性的介绍
- Android 工作问题记录
- android xml操作
- Android设置透明、半透明等效果
- Gradle Android Studio basic
- ubuntu下android源码下载
- Android代码设置Shape,corners,Gradient
- Android开源项目第三篇——优秀项目篇
- Android 视频播放之流媒体格式处理
- Android加载图片时出现OOM(OutOfMermary)的问题解决方案
- android LayoutInflater.inflate()的参数介绍
- cordova 5.3.3 android平台开发忽略的安全设置
- Android Studio常见问题--uses-sdk:minSdkVersion 11 cannot be smaller than version 15 declared in library
- android 获取设备上安装的非系统应用信息
- android知乎小圆圈刷新效果