How to recieve returned data from custom Dialog in android
<p>I have first activity with one button and one edittextbox.when i click that button i need to pass list of data from first activity to second activity.The second activity will displays that as list.If user selects one from the list.,that particular data should move back to the called activity(First activity) and should be displayed on the EditText box.How could i do that?</p>

<p>My FirstActivity:</p>

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

    Button click;
    EditText edit;

    ArrayList&lt;String&gt; site=new ArrayList&lt;String&gt;();
    String[] sitestr=new String[]{"monkey","donkey","Elephant","Baffalo"};


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        click=(Button)findViewById(R.id.click);
        edit=(EditText)findViewById(R.id.edit);

        click.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {


                  CustomizeDialog1 customizeDialog = new CustomizeDialog1(tu.this,sitestr);
                  customizeDialog.show();

            }
        });
}
</code></pre>

<p>Second:</p>

<pre><code>public class CustomizeDialog1 extends Dialog implements OnClickListener, OnItemClickListener {
  String selected_value;
  Button okButton;
  String hi[];
//  ListView list_view;

  public CustomizeDialog1(Context context,String[] value) {
    super(context);
    hi=value;
   // Log.v("Length",""+hi.length);
    /** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    /** Design the dialog in main.xml file */
    setContentView(R.layout.listviewinflate);

    ListView lst=(ListView)findViewById(R.id.list1);

     ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getContext(), android.R.layout.simple_list_item_1,hi);

     lst.setAdapter(adapter);
     lst.setOnItemClickListener(this);

   okButton = (Button) findViewById(R.id.cancel);
   okButton.setOnClickListener(this);
  }

  @Override
  public void onClick(View v) {
    /** When OK Button is clicked, dismiss the dialog */
    if (v == okButton)
      dismiss();
  }

  @Override
  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub
    selected_value=hi[arg2];
    //Log.v("selected_value", selected_value);
    Toast.makeText(getContext(), selected_value,Toast.LENGTH_SHORT).show();
}
}
</code></pre>
