如何在Android中通过屏幕进行自定义共享 [英] How to make custom share via screen in android
问题描述
我的应用程序具有一项共享功能。因此,在单击共享时,它应该显示要共享的应用程序列表。现在我正在使用此代码
My app has one share feature. So while click on share it should show the list of apps to be shared with. Right now I am using this code
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
它正在显示这样的对话框
and it is showing the dialog like this
但是我需要的是,我需要像这样的网格视图显示共享对话框。有可能这样做吗?如何自定义共享对话框窗口
But what I need is , I need to show the share dialog like a grid view like this. Is it possible to do so? How can I customize the share dialog window
推荐答案
您必须为此创建自定义对话框。
you have to create custom dialog for that. put this listview in some dialog.
请参考:
https://github.com/soarcn/BottomSheet
使用此代码获取可用的商品的ACTION_SEND
use this code to get available items of ACTION_SEND
Intent galleryIntent = new Intent(Intent.ACTION_SEND);
List<ResolveInfo> listGel = context.getPackageManager().queryIntentActivities(galleryIntent, 0);
for (ResolveInfo res : listGel) {
Log.e("package",res.activityInfo.packageName);
Log.e("name",res.activityInfo.name);
Log.e("proname",res.loadLabel(context.getPackageManager()).toString());
}
作为bottomSheet的其他选项,您可以也具有自定义列表视图,它将从屏幕底部弹出。
and as other option of bottomSheet you can have custom listview also, which will popup from bottom of screen.
这篇关于如何在Android中通过屏幕进行自定义共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!