以下是我通过 Share Action Provider 分享内容的方式:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
"Check the Link : " + url);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share with"));
我想用窗口设置共享样式。我想将文本颜色和荧光笔线条颜色从默认蓝色更改为我的自定义颜色。我正在使用全息灯主题。我不知道如何设置这些元素的样式。任何人都可以指出这样做的引用吗?
有没有办法通过样式访问 android.widget.ShareActionProvider 的属性?
最佳答案
我不知道如何设置对话框的样式,我在不同的设备上看到过不同的布局。但是您可以使用 PackageManager.queryIntentActivities(Intent intent, int flag)
来获取可以处理此 Intent 的所有 Activity 。并使用列表数据创建您自己的选择器。
编辑:一个演示
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com"));
PackageManager pm = getPackageManager();
final List<ResolveInfo> infos = pm.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
CharSequence[] names = new CharSequence[infos.size()];
for (int i = 0; i < infos.size(); i++) {
names[i] = infos.get(i).loadLabel(pm);
}
new AlertDialog.Builder(this).setItems(names,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ResolveInfo info = infos.get(which);
intent.setClassName(info.activityInfo.packageName,
info.activityInfo.name);
startActivity(intent);
}
}).show();
关于android - 在 Android 中设置 Share Action Provider 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227810/