当前位置:编程学习 > wap >>

写了个widget的demo,为什么上传安装到模拟器后在widget里找不到呢?

上传安装已经成功,但WIDGET里就是找不到,4.0.3的SDK,很久都找不到原因。。。

AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zy.hupuwidget"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >        
        <receiver android:name="Hupu" >
            <intent-filter >
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/hupu" />
        </receiver>
    </application>
</manifest>

res/xml 文件夹下 hupu.xml文件
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" >
    android:minWidth="150dip"
    android:minHeight="70dip"
    android:initialLayout="@layout/hupu"
    android:resizeMode="horizontal|vertical"
    android:widgetCategory="home_screen">
 </appwidget-provider>  

布局文件 layout下 hupu.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ListView
        android:id="@+id/newsList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_x="0dp"
        android:layout_y="0dp" >
    </ListView>

</AbsoluteLayout>

hupu.java文件
public class Hupu extends AppWidgetProvider
{

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds)
{
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.hupu);
ComponentName componentName = new ComponentName(context, Hupu.class);
appWidgetManager.updateAppWidget(componentName, remoteViews);

}
} --------------------编程问答-------------------- 没有Activity?也没有android:configure?
那widget启动的时候显示什么界面呢?
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,