日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > ChatGpt >内容正文

ChatGpt

动态更改屏幕方向LANDSCAPE与PORTRAIT 转

發(fā)布時間:2023/12/4 ChatGpt 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 动态更改屏幕方向LANDSCAPE与PORTRAIT 转 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
動態(tài)更改屏幕方向……LANDSCAPE與PORTRAIT package irdc.ex05_22; import android.app.Activity; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.Display; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class EX05_22 extends Activity { private TextView mTextView01; private Button mButton01; @Override public void onCreate(Bundle savedInstanceState) { ??super.onCreate(savedInstanceState); ??setContentView(R.layout.main); ?? ??mButton01 = (Button)findViewById(R.id.myButton1);? ??mTextView01 = (TextView)findViewById(R.id.myTextView1); ?? ??if(getRequestedOrientation()==-1) ??{ ????mTextView01.setText(getResources().getText ????(R.string.str_err_1001)); ??} ?? ?? ??mButton01.setOnClickListener(new Button.OnClickListener() ??{ ????@Override ????public void onClick(View arg0) ????{ ?????? ?????? ?????? ??????if(getRequestedOrientation()==-1) ??????{ ???????? ????????mTextView01.setText(getResources().getText ????????(R.string.str_err_1001)); ??????} ??????else ??????{ ????????if(getRequestedOrientation()== ???????????ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) ????????{ ?????????? ??????????setRequestedOrientation ??????????(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ????????} ????????else if(getRequestedOrientation()== ????????????????ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) ????????{ ?????????? ??????????setRequestedOrientation ??????????(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); ????????} ??????} ????} ????? ??}); } @Override public void setRequestedOrientation(int requestedOrientation) { ??// TODO Auto-generated method stub ?? ?? ??switch(requestedOrientation) ??{ ???? ????case (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE): ??????mMakeTextToast ??????( ????????getResources().getText(R.string.str_msg1).toString(), ????????false ??????); ??????break; ???? ????case (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT): ??????mMakeTextToast ??????( ????????getResources().getText(R.string.str_msg2).toString(), ????????false ??????); ??????break; ??} ??super.setRequestedOrientation(requestedOrientation); } @Override public int getRequestedOrientation() { ??// TODO Auto-generated method stub ?? ?? ??return super.getRequestedOrientation(); } public void mMakeTextToast(String str, boolean isLong) { ??if(isLong==true) ??{ ????Toast.makeText(EX05_22.this, str, Toast.LENGTH_LONG).show(); ??} ??else ??{ ????Toast.makeText(EX05_22.this, str, Toast.LENGTH_SHORT).show(); ??} } } AndroidMinifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="irdc.ex05_22" android:versionCode="1" android:versionName="1.0.0"> <application ??android:icon="@drawable/icon" ??android:label="@string/app_name"> ??<activity ????android:name=".EX05_22" ????android:label="@string/app_name" ????android:screenOrientation="portrait"> ????<intent-filter> ??????<action android:name="android.intent.action.MAIN" /> ??????<category android:name="android.intent.category.LAUNCHER" /> ????</intent-filter> ??</activity> </application> </manifest>

總結(jié)

以上是生活随笔為你收集整理的动态更改屏幕方向LANDSCAPE与PORTRAIT 转的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。