android - 在 Android 中设置 Share Action Provider 的样式

标签 android android-intent android-theme shareactionprovider

enter image description here

以下是我通过 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/

相关文章:

java - 使用 Retrofit GsonConverterFactory 反序列化 false 或对象的 json

android - Activity 中的 getIntent().removeExtra() 不适用于 android :launchmode ="singleTask"?

android - 在样式中使用 App 命名空间

android - 如何使用定义的属性动态更改颜色

android - 为 Android 中的所有 editTexts 设置一致的主题

android - 获取图标 native android?

android - 如何为每个应用程序使用一个 HttpClient?

android - 在 Android 中使用带有 Post Params 的 WCF Web 服务

android - 如何使用 Android 中的 Parcelable 接口(interface)通过 Intent 将包含可绘制参数的对象传递给另一个 Activity

android - 打开新帖子作为意向 - Facebook 移动版