方法1:在androidmanyfest.xml的activity中加入属性 android:screenOrientation="landscape"


        方法2:在oncreate中加入如下代码 if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);}

    

public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);   //启动横屏if(getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE){setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);}//点击屏幕事件  在开发中很有用的方法哟new GestureDetector(new  SimpleOnGestureListener(){@Overridepublic boolean onDoubleTap(MotionEvent e) {// TODO Auto-generated method stubreturn super.onDoubleTap(e);}@Overridepublic boolean onSingleTapConfirmed(MotionEvent e) {// TODO Auto-generated method stubreturn super.onSingleTapConfirmed(e);}@Overridepublic void onLongPress(MotionEvent e) {// TODO Auto-generated method stubsuper.onLongPress(e);}});}}



不要小看这个方法哟

    大家可不要小看了这么个例子哦,
    这个例子可是很有用的,
    点击事件是我们开发中必不可少的一个监听,大
   家可要用好它哦

更多相关文章

  1. android 简单例子
  2. android textview 自动链接网址 修改默认点击事件
  3. Android处理Bitmap的一些方法
  4. Android setMovementMethod() 方法
  5. android 触发AppWidget上控件事件来更新AppWidget
  6. Android切换主线程更新UI方法总结

随机推荐

  1. Android(安卓)adb远程调试
  2. Android点击菜单之后跳转到一个新的页面
  3. 利用power_profile.xml获取Android运行时
  4. FFmpeg 音频编码(PCM数据编码成AAC androi
  5. android 跳转时出现短暂的黑屏继承AppCom
  6. Android(安卓)Studio 1.2正式版发布,要如
  7. Android(安卓)开发中的日常积累
  8. Android(安卓)面试题总结之View(一)
  9. Android强制弹出,隐藏输入法.
  10. Android(安卓)string-array数据源简单使