- 浏览: 41266 次
- 性别:
- 来自: 济南
最新评论
-
kensunhu:
正是我想要的。典型的app ui布局。谢谢!
android UI - 仿威信tab样式 -
007007jing:
bing_zz 写道兄弟加油!谢谢
android2.3 api demo 学习系列(7)--App/Activity/Hello World -
bing_zz:
兄弟加油!
android2.3 api demo 学习系列(7)--App/Activity/Hello World
下面我们来学习下Screen Orientaiton的demo。
1、首先我们在values下面新建文件arrays.xml(用来在下拉列表中显示)
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- Used in app/Screen Orientation --> <string-array name="screen_orientations" <item>UNSPECIFIED</item> <item>LANDSCAPE</item> <item>PORTRAIT</item> <item>USER</item> <item>BEHIND</item> <item>SENSOR</item> <item>NOSENSOR</item> <item>SENSOR_LANDSCAPE</item> <item>SENSOR_PORTRAIT</item> <item>REVERSE_LANDSCAPE</item> <item>REVERSE_PORTRAIT</item> <item>FULL_SENSOR</item> </string-array> </resources>
2、我们在代码中定义相对应数组
final static int mOrientationValues[] = new int[] { ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_USER, ActivityInfo.SCREEN_ORIENTATION_BEHIND, ActivityInfo.SCREEN_ORIENTATION_SENSOR, ActivityInfo.SCREEN_ORIENTATION_NOSENSOR, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR, };
3、处理用户选择
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_activity_screen_orientation); mOrientation = (Spinner)findViewById(R.id.app_activity_screen_orientation); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.screen_orientations, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mOrientation.setAdapter(adapter); mOrientation.setOnItemSelectedListener( new OnItemSelectedListener() { public void onItemSelected( AdapterView<?> parent, View view, int position, long id) { setRequestedOrientation(mOrientationValues[position]); } public void onNothingSelected(AdapterView<?> parent) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }); }
效果图:
相关方法:
createFromResource()
方法创建一个新的 ArrayAdapter
, 定义了数组中得每一项如何显示在下来列表上. setDropDownViewResource(int)定义了下拉列表展开时每一项如何显示
.
AdapterView.OnItemSelectedListener
要求必须有 onItemSelected()
和onNothingSelected()
两个回调方法.根据其方面名我们就可以了解其用途。
public void setRequestedOrientation (int requestedOrientation)
改变activity的方向. 如果activity正在显示,则改变会立刻生效 (有可能导致activity重起). 否则改变会在activity下次可见的时候生效。
参数requestedOrientation可选值:
SCREEN_ORIENTATION_UNSPECIFIED
,SCREEN_ORIENTATION_LANDSCAPE
, SCREEN_ORIENTATION_PORTRAIT
,
SCREEN_ORIENTATION_USER
, SCREEN_ORIENTATION_BEHIND
, SCREEN_ORIENTATION_SENSOR
,
SCREEN_ORIENTATION_NOSENSOR
, SCREEN_ORIENTATION_SENSOR_LANDSCAPE
,
SCREEN_ORIENTATION_SENSOR_PORTRAIT
, SCREEN_ORIENTATION_REVERSE_LANDSCAPE
,
SCREEN_ORIENTATION_REVERSE_PORTRAIT
, SCREEN_ORIENTATION_FULL_SENSOR
.
.
发表评论
-
android2.3 api demo 学习系列(23)--App/Notification/StatusBarNotification
2012-07-07 19:51 1300apidemo-StatusBarNotification里面 ... -
android2.3 api demo 学习系列(22)--App/Notification/Notifying Service Controller
2012-07-06 14:56 1674因为还没有看到service的demo,这里先不对servic ... -
android2.3 api demo 学习系列(21)--App/Notification/Incoming Message
2012-07-06 11:55 2427现在我们开始学习android的Status Bar Noti ... -
android2.3 api demo 学习系列(20)--App/Menu
2012-07-06 09:58 1114现在来学习下menu的相关 ... -
android2.3 api demo 学习系列(19)--App/Intent and Launcher Shortcuts
2012-07-06 09:36 1062第一个demo:Intent,根据指定的类型,枚举出所有符合条 ... -
android2.3 api demo 学习系列(18)--App/Dialog
2012-07-06 09:13 958今天主要学习Dialog: 1、一般的dialog ... -
android2.3 api demo 学习系列(17)--App/Alarm/AlarmController and Alarm Service
2012-07-03 17:12 2146本次学习将apidemo中得两个demo:AlarmContr ... -
android2.3 api demo 学习系列(16)--App/Activity/Translucent and Blur activity
2012-07-03 11:47 1855本次同样是将apidemo中得两个demo合并起来学习:Tra ... -
android2.3 api demo 学习系列(15)--App/Activity/SetWallpaper
2012-07-03 11:00 1092本次示例我们整合了apidemo里面的两个demo:SetWa ... -
android2.3 api demo 学习系列(13)--App/Activity/Save & Restore
2012-07-02 17:29 1437前面文章android2.3 api demo 学习系 ... -
android2.3 api demo 学习系列(12)--App/Activity/Reorder Activitys
2012-07-02 16:45 960Reorder Activitys Demo主要是实现打开ac ... -
android2.3 api demo 学习系列(11)--App/Activity/Redirection
2012-07-02 15:52 831APIDEMO里面的redirection示例本身并没有新技术 ... -
android2.3 api demo 学习系列(10)--App/Activity/RecevieResult
2012-07-02 14:48 959在先前的文章 activity之间跳转传值 已经学习过这方面的 ... -
android2.3 api demo 学习系列(9)--App/Activity/QuickContactsDemo
2012-07-01 19:46 959现在我们来学习如何使用Content Provider来访问a ... -
android2.3 api demo 学习系列(8)--App/Activity/Preference State
2012-07-01 19:45 870android保存数据有很多种方式,其中最简单的就是使用Sha ... -
android2.3 api demo 学习系列(7)--App/Activity/Hello World
2012-06-29 14:03 1049学习android当然不能少了HelloWorld,接下来我们 ... -
android2.3 api demo 学习系列(6)--App/Activity/ForwardActivity
2012-06-29 13:50 799本次学习activity的跳转 1、构建intent ... -
android2.3 api demo 学习系列(5)--App/Activity/Dialog
2012-06-29 11:42 970前面我们已经学习了Custom Dialog 和 Custom ... -
android2.3 api demo 学习系列(4)--App/Activity/Custom Title
2012-06-29 11:26 1055android的标题栏默认是由android:lable定义的 ... -
android基础知识---Providing Resources
2012-06-29 10:42 775android的可使用的资源文件,google建议我们在开发应 ...
相关推荐
dlib-android-app See http://dlib.net for the main project documentation. See dlib-android for JNI lib. Refer to dlib-android/jni/jnilib_ex Grap the source $ git clone ...
安卓串口Demo程序 基于谷歌提供的源码android-serialport-api-android-serialport-api
1.D:\reactnative\RNTester> react-native bundle --platform android --dev false --entry-file js/RNTesterApp.android.js --bundle-output android/app/src/main/assets/RNTesterApp.android.bundle --assets-...
cordova-plugin-app-update App updater for Cordova/PhoneGap Demo Try it yourself: Just clone and install this demo. cordova-plugin-app-update-DEMO :tada: 如果喜欢它,请别忘了给我一颗鼓励的星 Support ...
这是很据android-serialport-api 自己简化的一个demo ,可以使用。原来android-serial-api的程序很多人反映都不能使用,所以自己写了这个,只有一个activity,可以做为你的学习参考。
WebRTCDemo-master_android-studio,webrtcdemo,p2p,android-studio编译
准备工作$ npm install启动服务找到对应的实例代码,然后启动 所在目录的 server/app.js如node ./src/upfiles-demo/demo-a1-form/server/app.jsnode ./src/upfiles-demo/demo-a2-formdata/server/app.jsnode ./src/...
可使用不同的图片作为地图...//下载demo http://mapp.android-libraries.com/download //学习地图 http://www.67tgb.com/?p=610 图片切割 http://www.67tgb.com/?p=597 http://mapp.android-libraries.com/slicingtool/
由于最近在做智能家居方向的产品,需要在App上对机器人实现一个简单的语音控制,于是开始寻找相应的解决方案,由于某种原因,google自己的语音识别API并不能在国内发挥作用,所以我们选择国内的科大讯飞语音识别服务...
android 项目 开发 demo <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.demo" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:...
Android串口操作,简化android-serialport-api的demo(附源码) 我把文中的源码导入 android studio 源码来自谷歌:android-serialport-api 涉及到的 jni 开发可以参考:【Android 应用开发】Android 开发 之 JNI...
OpenSAML-ref-project-demo-v3 这一个使用OpenSAML库的示例项目: 一个很简单的网址,其充当SP;同时该项目还包括一个很简单的IDP; SAML协议的交互将在这二者之间展开。项目启动之后,访问如下网址: ...
JavaScript人脸识别库Face-api.js的示例,无需安装nodejs,iis本地直接看效果。注意调用摄像头不能用IP访问,只能localhost,远程预览需要HTTPS;iis无扩展名文件若出现404,需在mime类型中添加扩展名【.】类型...
ci-demo-app-homebrew-tap CI演示应用程序的自制方法 安装 注册水龙头: brew tap embano1/ci-demo-app git@github.com:embano1/ci-demo-app-homebrew-tap 注意:如果您没有使用ssh设置git,您也可以使用...
这是android 2.3及2.3以后才能用的Sip (网络电话)相关接口使用的例子,实现了基本的网络电话功能(呼叫及被呼叫),用的是Android提供的编程接口。
DroidDrop - Remote Logging DroidDrop Remote logging give Android Developers the ability to log data from their applications to a drop on drop.io. ...Get a developer API Key from drop.io (free
android demo 的例子 用来学习android的效果 ,view 都是很好的帮助 还是中文的 通俗易懂 谢谢
文章地址 http://blog.csdn.net/ccslff/article/details/56675644
是一个简单的图像分类应用程序,演示了如何使用PyTorch Android API。 PyTorch演示应用 是一款功能完善的应用程序,其中包含两个展示柜。 相机应用程序运行量化模型以实时对图像进行分类。 还有一个基于文本的应用...
Android应用源码开发Demo,主要用于毕业设计学习。