如何分享listiview的内容(图像+文字)?
问题描述:
我有一个问题。我正在制作一个APP,其中有一个listview
,它有文本和图像。我想知道如何分享该人点击的内容。如何分享listiview的内容(图像+文字)?
这里是我的代码:
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.");
}
什么是你想要分享分享?你的屏幕的图片?这就是你所能做的一切。 –
发布适配器类请了解如何获取文本和图像值.. –