i have an activity which calls a dialog ...in the dialog i'm asking user to enter a password.Now i need this password in my activity.Is it possible and how ???...Thanks in advance !!!
Asked
Active
Viewed 2,038 times
3 Answers
1
You could create an activity that is themed as a Dialog
<activity android:theme="@android:style/Theme.Dialog">
and then call that activity with startActivityForResult(...)
as described here.

Juri
- 32,424
- 20
- 102
- 136
0
In the onClick
listener you will be passed the current Dialog
as one of the method arguments.
So you can do something like ((TextView) dialog.findViewById(R.id.passwordField)).getText().toString()
in the onClick
method.

Joseph Earl
- 23,351
- 11
- 76
- 89
-1
Have a look at this discussion AlertDialog Input Text ..
All you need is to call an Intent when appropriate button(positive or negative) is pressed.
See here :
Intent intent=new Intent(context,AnotherActivity.class);
EditText mUserText;
mUserText = (EditText) textEntryView.findViewById(R.id.txt_password);
String strpwd = mUserText.getText().toString();
intent.putExtra("my_password",strpwd);
startActivity(intent);

Community
- 1
- 1

Kartik Domadiya
- 29,868
- 19
- 93
- 104