android实现widget时钟示例分享

2019-12-10 20:08:55于海丽
易采站长站为您分析android实现widget时钟示例,需要的朋友可以参考下    

一、在 AndroidManifest.xml文件中配置Widgets:

 

复制代码
<manifest xmlns:android="http://www.easck.com/apk/res/android"
    package="com.example.widget"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <receiver android:name=".TimeWidgetProvider" >
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/timewidget_info" />
        </receiver>
        <service android:name=".TimerService"></service>
    </application>
</manifest>

 

二、在项目的res目录下建立xml目录,并且创建 timewidget_info.xml 文件,内容如下:

 

复制代码