在小部件(appwidget)一个页面要根据不同条件切换不同的布局
比如小部件
上午显示一个列表 ( 打球 运动 做饭)
下午显示一个列表更换一下内容(学习 看书 看电影)
请问大大 代码可以实现吗??
求简单列子(安卓源码)!!!谢谢!!
这种东西多看下基础只是就可以解决了,没什么技术含量
你需要什么样子的界面,用画画本画出来大概的样子
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")
.setShortLabel("Web site")
.setLongLabel("Open the web site")
.setIcon(Icon.createWithResource(mContext, R.drawable.ic_btn_exam_checked))
.setIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.mysite.example.com/")))
.build();
ShortcutInfo shortcut2 = new ShortcutInfo.Builder(this, "id2")
.setShortLabel("Web site")
.setLongLabel("Open the web site")
.setIcon(Icon.createWithResource(mContext, R.drawable.ic_btn_exam_checked))
.setIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.mysite.example.com/")))
.build();
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut,shortcut2));
}