Android实现振动效果_全屏_无标题_横屏【未测试】
2013-10-14 15:06
483 查看
1
2
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/btn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="振动测试" /> </LinearLayout>
2
package com.suxh.activity; import android.app.Activity; import android.app.Service; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Vibrator; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.WindowManager; import android.widget.Button; public class Activity1 extends Activity { private Button btn; private Vibrator mVibrator01; //声明一个振动器对象 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置为无标题栏 requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置为全屏模式 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置为横屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentView(R.layout.main); btn = (Button)findViewById(R.id.btn); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mVibrator01 = ( Vibrator ) getApplication().getSystemService(Service.VIBRATOR_SERVICE); mVibrator01.vibrate( new long[]{100,10,100,1000},-1); } }); } }
相关文章推荐
- Android sd卡使用解说
- android适配器数据类型不用HashMap原因
- Android中Bitmap缓存池zz
- Android中Bitmap和Drawable转换(zz)
- android编译模块
- android中java.lang.NoClassDefFoundError异常的解决方法之一
- Android Intent 用法全面总结
- 对android:gravity的理解
- 【Android】保存Fragment切换状态
- 转载_最封闭的开源系统,话说Android的八宗罪
- android 在service中使用toast
- Android 摄像头的使用
- [Android开发常见问题-23] Android Handler、Message完全解析,带你从源码的角度彻底理解
- android 在代码中动态设置字体颜色需要注意的问题
- android获取当前文字的总体长度的方法
- 我的Android入门书
- android 如何设置透明度
- Android中设置EditText默认无焦点
- android SQLite 优化
- Android的设置界面及Preference使用