Android widget如何添加到桌面
请问一下在程序里如何添加一个widget到桌面
网上搜了好多都说要用户手动添加
有办法用程序自动添加到桌面么
[解决办法]
不知道楼主的意思是否是要添加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,再执行相关操作
[解决办法]
widget 是窗口部件吧 !