Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I create an AlertDialog inside a fragment which contains 3 EditText (using LinearLayout as the layout inside AlertDialog). But I got an error when trying to getTextt from the three of the EditText. Here's the code:

C#
AlertDialog.Builder alert = new AlertDialog.Builder(this.getActivity());
	        	  alert.setTitle("Add New Supplier");
	        	  //Set an EditText view to get user input
	        	  inputname = new EditText(Supplier.this.getActivity());
	        	  inputadd = new EditText(Supplier.this.getActivity());
	        	  inputtelp = new EditText(Supplier.this.getActivity());
	        	  	        	  
	        	  inputname.setHint("Supplier's Name");
	        	  inputadd.setHint("Supplier's Address");
	        	  inputtelp.setHint("Supplier's Telp");
	        	  
	        	  inputtelp.setInputType(InputType.TYPE_CLASS_NUMBER);
	        	 
	        	  LinearLayout lay = new LinearLayout(Supplier.this.getActivity());
	        	  lay.setOrientation(LinearLayout.VERTICAL);
	        	  lay.addView(inputname);
	        	  lay.addView(inputadd);
	        	  lay.addView(inputtelp);
	        	  alert.setView(lay);

alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {						
						new AddNewSupplier().execute();
}
	        	  });

Then inside the AddNewSupplier class

C#
protected String doInBackground(String... arg0) {
            String namesupplier = inputname.getText().toString();
            String addsupplier = inputadd.getText().toString();
            String telpsupplier = inputtelp.getText().toString();


            Toast.makeText(Supplier.this.getActivity(), namesupplier + "\n" + addsupplier + "\n" + telpsupplier, Toast.LENGTH_LONG).show();


What's wrong?
Any help, Thanks

-Rudy
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900