Hello, I have a question. I am making an APP, in which it has a listview that has texts and an image. I'd like to know how I can share the content that the person clicked on.
Here is my code:
// DECLARANDO COMPONENTES
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,
};
String[] ac_Contra_ComoVotou={
"SIM"
};
@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)
{
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);
}
});
THANK YOU VERY MUCH !!!