Consultation about close the keyboard in my android program
<p>when i return from my dialog the keyboard still open even if i close it.</p>

<p>my dialog from the maim</p>

<pre><code>  txtWeight = (TextView) findViewById(R.id.txtWeight);
        txtWeight.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                data myDialog = new data(context, "ME", new OnReadyListener());
                myDialog.show();
            }
        });
</code></pre>

<p>in the dialog</p>

<pre><code>public class data extends Dialog {
    private ReadyListener readyListener;
    public String KG;
    private EditText txtGK;
    public data(Context context, String name,ReadyListener readyListener) {
        super(context);       
        this.readyListener = readyListener;
    }
    public interface ReadyListener {
        public void ready(String name);
    }

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.data);
        setTitle("the title");
        Button btnClose;
        Button btnexit;
        txtGK = (EditText) findViewById(R.id.txtWeight);
        txtGK.setText("");
        btnClose = (Button) findViewById(R.id.button1);
        btnClose.setOnClickListener(new Close());
        btnexit = (Button) findViewById(R.id.button2);
        btnexit.setOnClickListener(new exit());
    }

    private class Close implements android.view.View.OnClickListener {
        public void onClick(View v) {
            KG=txtGK.getText().toString();
            readyListener.ready(KG);
            data.this.dismiss();
        }
    }

    private class exit implements android.view.View.OnClickListener {
        public void onClick(View v) {
            data.this.dismiss();
        }
    }
}
</code></pre>

<p>and return from the dialog to the main</p>

<pre><code> private class OnReadyListener implements data.ReadyListener {
        public void ready(String name) {
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(txtWeight.getWindowToken(), 0);

            txt1 = name;
            txtWeight.setText(txt1);
            String currentDateTimeString =              
            imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(txtWeight.getWindowToken(), 0);
        }
    }
</code></pre>

<p>as you can see i try to close the keyboard like this:</p>

<pre><code>InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(txtWeight.getWindowToken(), 0);
</code></pre>

<p><strong>but the keyboard not close</strong>          </p>
