Note that there are some explanatory texts on larger screens.

plurals
  1. POEditText Value in Android
    text
    copied!<p>I have a custom dialog with me. In which an editText id there, I am reading input through editText, putting the input to a string. This code is followed by a thread (sub) to handle one url. I want to use this string in the thread mentioned. But the thread is getting invoked before I type to the editText. How can i dynamically use the same text from the userinput inside the thread? Thanks in advance..</p> <p>public void onClick(View v) {</p> <pre><code> switch (v.getId()) { case R.id.i1: MyDevice.getInstance().currentUserImageId=R.drawable.jerry1; MyDevice.getInstance().userName="You"; MyDevice.getInstance().facebook=0; this.finish(); break; case R.id.i2: MyDevice.getInstance().currentUserImageId=R.drawable.chaplin1; MyDevice.getInstance().userName="You"; MyDevice.getInstance().facebook=0; this.finish(); break; case R.id.i3: MyDevice.getInstance().currentUserImageId=R.drawable.budy; MyDevice.getInstance().userName="You"; MyDevice.getInstance().facebook=0; this.finish(); break; case R.id.facebook: final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.usernamefbdialog); dialog.setTitle("Enter Facebook Username"); Button dialogButton = (Button) dialog.findViewById(R.id.done); // if button is clicked, close the custom dialog dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EditText edit=(EditText)dialog.findViewById(R.id.username); text=edit.getText().toString(); dialog.dismiss(); } }); dialog.show(); Thread thread = new Thread(new Runnable() { @Override public void run() { try { MyDevice.getInstance().bitmap=getUserPic(text); MyDevice.getInstance().facebook=1; ImageView facebookImg=(ImageView) findViewById(R.id.facebookimg); facebookImg.setImageBitmap(MyDevice.getInstance().bitmap); } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); break; } } </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