1
Activity 1:
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
//Pega o item que foi selecionado.
ItemPromo item = adapterListView.getItem(arg2);
//Demostração
//Toast.makeText(this,item.getTexto(), Toast.LENGTH_LONG).show();
Intent intent = new Intent(this,Promocao.class);
intent.putExtra("valor1",item.getTexto());
intent.putExtra("valor2",item.getIconeRid());
startActivity(intent);
}
Activity 2:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_promocao);
lblTeste = (TextView) findViewById(R.id.lblTeste);
imgTeste = (ImageView) findViewById(R.id.imgTeste);
Bundle bundle = getIntent().getExtras();
if(bundle.containsKey("valor1")){
String valor = bundle.getString("valor1");
lblTeste.setText(valor);
}
else if(bundle.containsKey("valor2")){
int v = bundle.getInt("valor2");
imgTeste.setImageAlpha(v);
}
}
If bitmap is a file or resource and you have its ID or file path, it’s always better to pass it than the bitmap itself. What saves a good amount of memory resources and can even prevent problems in the App, since the maximum size of an Intent is around 1mb.
– Luiz
You are right, when the application allows the image to be recovered by a URL or the path is worth using this resource and pass a String. As to that of 1MB did not know, thank you for the information.
– Giancarlo Abel Giulian