微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 怎样自定义Intent选择界面的标题

怎样自定义Intent选择界面的标题

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
在Intent选择界面,系统会列出所有符合Intent筛选条件的Activity。Intent选择界面的标题默认统一显示“Complete action using”,如果想要使用自己定义的标题,应该怎样修改?
[SOLUTION]
可以使用 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中

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top