With this code, I can easily insert dynamically some layouts. The layout contains a Button
, which I want to launch startActivityForResult
. Now when I get the result (text), I want to set it on the Button
.
btnAggiungiCampo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popup = new PopupMenu(this, btnAggiungiCampo);
popup.getMenuInflater().inflate(R.menu.menu_campi, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
View child = null;
if (item.getTitle().equals(getString(R.string.Text))) {
child = getLayoutInflater().inflate(R.layout.inflate_campo, null);
rlCampi.addView(child);
Button btnGeneraPSW = (Button) child.findViewById(R.id.imageButton3);
btnGeneraPSW.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent inte = new Intent(this, Genera_password.class);
startActivityForResult(inte, REQ_CODE_ACT1);
}
});
}
}
}
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQ_CODE_ACT1) {
// how can I set??
}
}
}