如何共享列表视图(图像+文本)的内容?

How to share the contents of a listiview (Image + Text)?

我有一个问题。我正在制作一个应用程序,其中有一个 listview,其中包含文本和图像。我想知道如何分享用户点击的内容。

这是我的代码:

private ListView list;

// ARRAY CONTRA-AC
String[] ac_Contra = {
    "Flaviano Melo",
    "Jéssica Sales"
};

Integer[] ac_Contra_Imgid = {
    R.drawable.flaviano_melo,
    R.drawable.jessica_sales,
};

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // VINCULANDO COMPONENTES
    list = (ListView) findViewById(R.id.list);

    // CAPTURANDO INFORMAÇÕES DE OUTRA ACTIVITY
    Bundle extra = getIntent().getExtras();

    // Condição para execução do comando
    if (extra != null)
    {
        String textoTransferido1 = extra.getString("CONTRA");
        String textoTransferido2 = extra.getString("FAVOR");
        String textoTransferido3 = extra.getString("INVESTIGADOS");

        // CONDIÇÃO - ESTADO AC
        if ("CONTRA-AC".equals(textoTransferido1))
        {
            CustomListAdapter adapter=new CustomListAdapter(this, ac_Contra, ac_Contra_Imgid, ac_Contra_partido,ac_Contra_ComoVotou);
            list = (ListView)findViewById(R.id.list);
            list.setAdapter(adapter);
        }

        // EVENTO DE CLIQUE
        list.setOnItemClickListener(new OnItemClickListener()
        {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)
            {
            }
        });
    }
}

您必须创建一个自定义适配器并添加一个发送按钮,然后在该按钮上添加 onClisckListener 以通过 whatsapp 分享

Uri imageUri = Uri.parse(pictureFile.getAbsolutePath());
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
//Target whatsapp:
shareIntent.setPackage("com.whatsapp");
//Add text and then Image URI
shareIntent.putExtra(Intent.EXTRA_TEXT, picture_text);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

try {
    startActivity(shareIntent);
} catch (android.content.ActivityNotFoundException ex) {
    ToastHelper.MakeShortText("Whatsapp have not been installed.");
}