请问一下在程序里如何添加一个widget到桌面网上搜了好多都说要用户手动添加 
有办法用程序自动添加到桌面么

解决方案 »

  1.   

    看你的需求了 
    是需要在开机的时候自动添加到桌面的话 
    需要在手机的data/system/appwidgets.xml里面加上你的widget
      

  2.   

    永久加入要写数据库的,launcher的provider中有的,
      

  3.   

    不知道楼主的意思是否是要添加widge窗口里面的控件,目前只能在layout手动配置啊,TextView,类似于label,另一个是Button,下面是在layout里面的布局文件代码<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
      <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
      />
      <Button
        android:id="@+id/myButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_button1"
      />
    </LinearLayout>
    在代码中使用要导入包
    import android.widget.TextView;
    import android.widget.Button;然后可以通过findViewById去获取控件Id,再执行相关操作
      

  4.   

      widget 是窗口部件吧 !
      

  5.   


    你需要手动计算,你的widget占多少格,当前桌面有的第几个屏有多少空格,你可以看下launcher的代码,快捷方式的创建同样的道理。
      

  6.   

    可以的呀,不是有个工具droiddraw么,挺好用的啊。把控件拖进去,生成代码放到xml里面就行了
      

  7.   

    直接写进laucher的provider里面么
      

  8.   

    有demo代码或者链接么~我看看
      

  9.   

    直接写到Launcher的代码里面也可以实现,如那个google Search
      

  10.   

    我是想通过自己的apk放一个widget到桌面 类似那种有米便签那种如何放到桌面去的哇?