How to change EditText hint in main context with AlertDialog
<pre><code>private EditText result = (EditText) findViewById(R.id.editText1);
final String[] dropdownList ={"a123", "b456"};

public void onCreate(...) {
    ...
    alert();
}


private void alert() {
    new AlertDialog.Builder(this)
    .setTitle("select")
    .setSingleChoiceItems(dropdownList, checkedItem, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.setHint("some tips");
                }
        )}.show()
</code></pre>

<p>EditText result is already have a hint in layout.xml, but I want to change the hint in </p>

<p>EditText result, but the code above throws a NullPointerException, what's the problem? </p>

<p>edit:</p>

<pre><code>public class AAA extends Activity {

private EditText result;
private String[] dropdownList = {"A123", "A456"};
private int checkedItem = 0; 

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    result = (EditText) findViewById(R.id.editText1);
    alert();
}

private void alert() {
    new AlertDialog.Builder(this)
    .setTitle("select")
    .setSingleChoiceItems(dropdownList, checkedItem, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.setHint("some tips");
                }
    }).show();
}
</code></pre>

<p>}</p>
