The code for add button dynamically when user need it , When user click on “addService” this code take (a name for button and a value to use in intent for this button) from second activity then add button dynamically in this activity with the name and intent and user can click it for service . How to save the button that add dynamically by user ? ..............................................................................
Button btn = new Button(MainActivity.this);
btn.setText(buttonName);
layout.addView(btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String phone = serviceNum;
Intent e = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", phone, null));
startActivity(e);
}
});
Aucun commentaire:
Enregistrer un commentaire