Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <code>Bundles</code></p> <p><strong>In Activity 1</strong></p> <pre><code>String your_string = "Hello, World!"; Bundle bundle = new Bundle(); bundle.putString("The key for this string", your_string ); Intent ActivityToLaunch= new Intent(this, ActivityB.class); ActivityToLaunch.putExtras(bundle); this.startActivity(ActivityToLaunch); </code></pre> <p><strong>In Activity 2</strong></p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout2); //Setup some layout, set to your own String content = getIntent().getExtras().getString("The key for this string"); TextView text = (TextView) findViewById(R.id.tv); text.setText(content); } </code></pre> <p><strong>The thread starter said that he wanted to raise a custom dialog, so here goes the edit</strong></p> <p>This is my class which will generate a custom Dialog:</p> <pre><code>public class ErrorDialog { TextView msgTextView; Button toSettings; final Context c; Dialog errorDialog; /** * @param c The Context * @param title Title of the Dialog * @param msg Message og the Dialog * @param textOnButton The text on the button */ public ErrorDialog(final Context c, String title, String msg, String textOnButton) { this.c = c; errorDialog = new Dialog(c); errorDialog.setContentView(R.layout.error_dialog); errorDialog.setTitle(title); msgTextView = (TextView) errorDialog.findViewById(R.id.errorMSG); msgTextView.setText(msg); toSettings = (Button) errorDialog.findViewById(R.id.toSettings); toSettings.setText(text); toSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //doing operations when the user clicks my button in the dialog. } }); errorDialog.show(); errorDialog.setCancelable(true); } } </code></pre> <p>Use this class this way:</p> <pre><code>new ErrorDialog(getApplicationContext(), "My Title", "My Message to the user", "Text on the button"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload