Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 01-07-2010, 04:52 AM   #1
Junior Member
 
Join Date: Dec 2009
Posts: 4
Friends: 0
View Anjul's Profile   View Anjul's Photo Album   View Anjul's Blog   View Social Groups
On a button click say status, i want that a pop up window appears which lets a user set a status message and which in turn is displayed in the status message field.
I thought of using a customized alert dialog.
here is the xml file of my dialog layout:

I am getting the dialog. However onpositiveButtonClick
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:padding="10dp"
              >
    <EditText android:id="@+id/text"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
            
              />
                            
</LinearLayout>
in the java file, i am displaying the dialog as follws:
Code:
AlertDialog.Builder builder;
					    	Context mContext = MyProfileActivity.this;
					    	LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
					    	final View layout = inflater.inflate(R.layout.status_dialog,
					    	                               (ViewGroup) findViewById(R.id.layout_root));
					    	
					    	builder = new AlertDialog.Builder(mContext);
					    	builder.setView(layout);
					    	builder.setTitle("Add Status message").
					    		setCancelable(false).
					    		setPositiveButton("Update Status", new DialogInterface.OnClickListener() {
								
								@Override
								public void onClick(DialogInterface dialog, int which) {
									EditText text = (EditText) layout.findViewById(R.id.text); // compile time error
					    			TextView statusTxt = (TextView)findViewById(R.id.status_txt);
					    			statusTxt.setText(text.getText().toString());
					    			MyProfileActivity.this.dismissDialog(DIALOG_STATUS);
								}
							}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
								
								@Override
								public void onClick(DialogInterface dialog, int which) {
									dialog.dismiss();
									
								}
							});
					    	alertDialog = builder.create();
Now i am getting the dialog, but i am not able to retrieve the text entered the text field on positive(update) button click..
Please suggest me a way to retrieve my editText view in onclick() method.
Anjul is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Customized Ringtones?? NikkiSixx Droid Eris 4 01-12-2010 11:08 PM
Is There a Way to Message Alert? Stefani Shock T-Mobile, Vodafone, Sprint, Verizon, Rogers, AT&T etc. 0 05-21-2009 11:52 AM
AT&T working on customized Android devices Andor Android Chat 0 04-02-2009 03:44 PM
Making your G1 even more customized dchamber Android Games And Applications 5 03-13-2009 09:05 AM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 08:21 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2012 TalkAndroid.com. All rights reserved.