Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>on button click it shows an alterDialogue for user to input. once some value is inputted it shows it in the corresponding textview. Here is the whole code:</p> <pre><code>package com.example.testandroidapp; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends Activity { TextView input1; String value = ""; int bias; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button grayScaleFilterButton = (Button) findViewById(R.id.button1); input1 = (TextView) findViewById(R.id.textView1); grayScaleFilterButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(v .getContext()); alert.setTitle("Title"); alert.setMessage("Message"); // Set an EditText view to get user input final EditText input = new EditText(MainActivity.this); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { value = input.getText().toString(); // Convert the inputted string into Integer bias = Integer.parseInt(value); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } }); input1.setText(value); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } </code></pre>
 

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