Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid EditText setText not updating the text
    primarykey
    data
    text
    <p>Hi there. I dont know what is happening. I am trying to change the text of an <code>EditText</code> when creating a <code>DialogFragment</code>, but the <code>EditText</code> is not updating the text. If I call <code>getText().length()</code> I notice that the content of the <code>EditText</code> changed. But, the visual keeps the same, just empty.</p> <p><strong>Why?</strong></p> <p>Thanks in advance people</p> <p>Here is the code:</p> <pre><code>public class ItemNameDialog extends DialogFragment { @Override public Dialog onCreateDialog(final Bundle bundle) { System.out.println("ON CREATE DIALOG WAS CALLED"); //This appears on LogCat, so this method is called.. the problem is not that AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Configure an item to count:"); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.itempick_layout, null); builder.setView(view); final CheckBox box = (CheckBox) view.findViewById(R.id.itemSenseCheckBox); final EditText itemNameBox = (EditText) view.findViewById(R.id.itemNameText); final Spinner spinner = (Spinner) view.findViewById(R.id.itemsDefault); final int viewIDClicked = getArguments().getInt(clickableViewID); final String actualName = getArguments().getString(actualNameItemView); System.out.println("H - before: " + itemNameBox.getText().toString().length()); //it appears on logcat "H - before: 0" itemNameBox.setText(actualName); System.out.println("H - after: " + itemNameBox.getText().toString().length()); //it appears on logcat "H - before: 3" so why not changing ? return builder.create(); } } </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.
 

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