EditText.setText error
<p>RESOLVED! The problem is that I used this.findViewById, but I will use dialog.findViewById. TNX TO ALL AND I BEG YOUR PARDON!</p>

<p>I've a strange (for me) problem. I try to write in a edittext with a string readed from a cursor, and i know that's the correct way:</p>

<pre><code>EditText myText;

     final Dialog dialog = new Dialog(this);
     dialog.setContentView(R.layout.login);
     dialog.setTitle("Login");
     dialog.setCancelable(true);

     Cursor lista=db.listaParametri();

     try
        {
            while (lista.moveToNext())
            {

                if (lista.getString(0).equals("username"))
                {

                    myText =  (EditText) this.findViewById(R.id.username);

                    Log.d("log", lista.getString(1));

                    myText.setText( lista.getString(1) );




                }



            }
        }
        finally
        {
            lista.close();
        }
</code></pre>

<p>But when try to write whit settext() return this error:</p>

<pre><code>06-10 09:43:01.829: E/AndroidRuntime(279): FATAL EXCEPTION: main
06-10 09:43:01.829: E/AndroidRuntime(279): java.lang.NullPointerException
06-10 09:43:01.829: E/AndroidRuntime(279):  at it.axiomatic.epsoft.sms.EpsoftSMSActivity.setup_parametri(EpsoftSMSActivity.java:147)
06-10 09:43:01.829: E/AndroidRuntime(279):  at it.axiomatic.epsoft.sms.EpsoftSMSActivity.onOptionsItemSelected(EpsoftSMSActivity.java:73)
06-10 09:43:01.829: E/AndroidRuntime(279):  at android.app.Activity.onMenuItemSelected(Activity.java:2195)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
06-10 09:43:01.829: E/AndroidRuntime(279):  at android.view.View$PerformClick.run(View.java:8816)
06-10 09:43:01.829: E/AndroidRuntime(279):  at android.os.Handler.handleCallback(Handler.java:587)
06-10 09:43:01.829: E/AndroidRuntime(279):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-10 09:43:01.829: E/AndroidRuntime(279):  at android.os.Looper.loop(Looper.java:123)
06-10 09:43:01.829: E/AndroidRuntime(279):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-10 09:43:01.829: E/AndroidRuntime(279):  at java.lang.reflect.Method.invokeNative(Native Method)
06-10 09:43:01.829: E/AndroidRuntime(279):  at java.lang.reflect.Method.invoke(Method.java:521)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-10 09:43:01.829: E/AndroidRuntime(279):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-10 09:43:01.829: E/AndroidRuntime(279):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>What's up? Tnx!</p>
