AppWidget 1.Widget的layout显示布局文件 2.一个AppWidget的配置文件 xml/provider_info.xml,该文件配置了widget可以占用的屏幕长宽、更新频率,所显示的布局文件(就是上面的那个布局文件)等 3.准备好一个处理widget请求的Java文件,继承了AppWidgetProvider类 4.配置AndroidManifest.xml文件,增加一个receiver标签,加action和meta-data AppWidget Manifest.xml <receiver android:label="Hello,App Widget" android:name="HelloWidgetProvider"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"> </action> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/provider_info" /> </receiver> Sensor传感器 传感器类型常量 内部整数值 中文名称Sensor.TYPE_ACCELEROMETER1加速度传感器Sensor.TYPE_MAGNETIC_FIELD2磁力传感器Sensor.TYPE_ORIENTATION 3方向传感器Sensor.TYPE_GYROSCOPE 4陀螺仪传感器Sensor.TYPE_LIGHT 5环境光照传感器Sensor.TYPE_PRESSURE 6压力传感器Sensor.TYPE_TEMPERATURE 7温度传感器Sensor.TYPE_PROXIMITY 8距离传感器 Sensor //从系统服务中获得传感器管理器 SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); // 获取加速度传感器 Sensor acceleromererSensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // 定义传感器事件监听器 SensorEventListener acceleromererListener = new SensorEventListener() {…}; //在传感器管理器中注册监听器 sm.registerListener(acceleromererListener, acceleromererSensor, SensorManager.SENSOR_DELAY_NORMAL); 获取某种传感器的默认传感器 Sensor defaultGyroscope = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); 获取某种传感器的列表 List<Sensor> pressureSensors = sensorManager.getSensorList(Sensor.TYPE_PRESSURE); 获取所有传感器的列表 List<Sensor> allSensors = sensorManager.getSensorList(Sensor.TYPE_ALL); TabActivity <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id = "@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <TabWidget android:id = "@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> <FrameLayout android:id = "@android:id/tabcontent" android:paddingTop="65dp" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id = "@+id/vtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff0000" /> </FrameLayout> </TabHost> code: //定义第一个标签 tabHost.addTab(tabHost.newTabSpec("OneTab") .setIndicator("OneTab", getResources().getDrawable(android.R.drawable.star_on)) .setContent(R.id.vtext)); //定义第二个标签 tabHost.addTab(tabHost.newTabSpec("TwoTab") .setIndicator("TwoTab", getResources().getDrawable(android.R.drawable.star_off)) .setContent(R.id.vtext)); //定义第3个标签 tabHost.addTab(tabHost.newTabSpec("3Tab") .setIndicator("3Tab", getResources().getDrawable(android.R.drawable.star_big_on)) .setContent(R.id.vtext)); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {…} PopupWindow 1.一个Layout文件,把PopupWindow要显示的内容组织好; 2.LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View vPopupWindow=inflater.inflate(R.layout.popupwindow, null, false); final PopupWindow pw= new PopupWindow(vPopupWindow,300,300,true); //显示popupWindow对话框 pw.showAtLocation(parent, Gravity.CENTER, 0, 0); TextSwitcher,ImageSwitcher 在layout中加入TextSwitcher 代码处理: final TextSwitcher tv = (TextSwitcher) findViewById(R.id.vtext); tv.setInAnimation(AnimationUtils.loadAnimation(tabactivity.this, android.R.anim.fade_in)); tv.setOutAnimation(AnimationUtils.loadAnimation(tabactivity.this, android.R.anim.fade_out)); tv.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { // TODO Auto-generated method stub TextView t = new TextView(tabactivity.this); t.setGravity(Gravity.CENTER); t.setTextSize(36); return t; } }); 。。。 tv.setText("TextSwitcher Text");