欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

android intent使用定义标题

程序员文章站 2023-12-05 17:24:40
可以使用 intent.createchooser() 的方法来创建 intent,并传入想要的 sting 作为标题。 以wallpaper 选择框为例,当在launch...
可以使用 intent.createchooser() 的方法来创建 intent,并传入想要的 sting 作为标题。

以wallpaper 选择框为例,当在launcher workspace的空白区域上长按,会弹出wallpaper的选择框,选择框的标题为”choose wallpaper from”,如下:
复制代码 代码如下:

private void startwallpaper() {
showworkspace(true);
final intent pickwallpaper = new intent(intent.action_set_wallpaper);
intent chooser = intent.createchooser(pickwallpaper, gettext(r.string.chooser_wallpaper));
// note: adds a configure option to the chooser if the wallpaper supports it
startactivityforresult(chooser, request_pick_wallpaper);
}

其中,r.string.chooser_wallpaper对应的字串内容就是”choose wallpaper from”,定义在launcher2的strings.xml中