用代码旋转屏幕

代码 1 btnRotate.setOnClickListener(new OnClickListener() {
 2             @Override
 3             public void onClick(View v) {
 4                 int r = Math.abs(getRequestedOrientation());
 5                 Log.d("DEBUG",Integer.toString(r));
 6                 Log.d("DEBUG","LANDSCAPE =" + Integer.toString(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));
 7                 Log.d("DEBUG","PORTRAIT  =" + Integer.toString(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT));
 8                 if (r == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
 9                     Log.d("DEBUG", "To " + Integer.toString(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT));
10                     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
11                 } else if (r == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
12                     Log.d("DEBUG", "To " + Integer.toString(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));
13                     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
14                 }
15             }
16         });

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏Jack-Cui

83. Remove Duplicates from Sorted List(Linked List-Easy)

Given a sorted linked list, delete all duplicates such that each element appear ...

1947
来自专栏Jack-Cui

21. Merge Two Sorted Lists(Linked List-Easy)

Merge two sorted linked lists and return it as a new list. The new list should b...

18910
来自专栏aCloudDeveloper

LeetCode: 2_Add Two Numbers | 两个链表中的元素相加 | Medium

题目: You are given two linked lists representing two non-negative numbers. The di...

2046
来自专栏desperate633

LeetCode 25. Reverse Nodes in k-Group分析代码

我们设计一个翻转k的算法 head -> n1 -> n2 ... nk -> nk+1 => head -> nk -> nk-1 .. n1 -> nk...

1002
来自专栏用户画像

剑指offer 删除链表中的重复的结点

在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表1->2->3->3->4->4->5 处理后为 1...

983
来自专栏一个会写诗的程序员的博客

Android中的WebView之loadDataWithBaseURL()与loadData()Android中的WebView之loadDataWithBaseURL()与loadData()

1081
来自专栏猿人谷

Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass. For...

1897
来自专栏计算机视觉与深度学习基础

Leetcode 148 SortList

Sort a linked list in O(n log n) time using constant space complexity. 链表排序,n...

1967
来自专栏计算机视觉与深度学习基础

Leetcode 24 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head. For ex...

21310
来自专栏计算机视觉与深度学习基础

Leetcode 234. Palindrome Linked List

Given a singly linked list, determine if it is a palindrome. Follow up: Could...

2057

扫码关注云+社区

领取腾讯云代金券