I have an Activity which have one button and two TextView.When i press button on activity a dialog box appear which has two editText and Done Button.I want when user give some value in EditText in dialog box and press DOne . Then This Dialog Box disappear and show the previous activity and set the text (Which i have got from the User in Dialog ) on Activity textView...How can i do this....
Asked
Active
Viewed 174 times
-2
-
first try yoruself and shows us what you have done. – Nirav Tukadiya Jan 07 '13 at 06:13
-
i Have tried it...But it give me error ..I have created a method in activity which take two arguments and set on text view ..And in the Dialog box i have called that method in Done button action listener.But its give error. Unfortunality....and app will close – Malik Ehtasham Jan 07 '13 at 06:15
1 Answers
0
Refere this Link :
First Onclick() of Button to call Your Activity Like this;
Intent intent = new Intent(getActivity(), DIALOG_ACTIVITY.class);
startActivityForResult(intent, REQUEST_CODE);
This will open Dialog Activity & OnClick() of Done Button Set Result in Onclick() method
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
This Result you will get into Your Main Activity just override this result
@Override
Protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
}
& Dont forget to declare Activity in Manifest File Like this.
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DIALOG_ACTIVITY"
android:label="@string/app_name">
</activity>

Dixit Patel
- 3,190
- 1
- 24
- 36