Posts

Showing posts with the label alert Dialog with xml layout

Creating Input Dialog Box with Xml Layout File

Image
Creating Input Dialog Box with Xml Layout File Call this Method in your Actvity private void OpenCategroyDialogBox () { LayoutInflater layoutInflater = LayoutInflater . from ( this ); View promptView = layoutInflater . inflate ( R . layout . addnewcategory , null ); final AlertDialog . Builder alert = new AlertDialog . Builder ( this ); alert . setTitle ( "Add New Category" ); alert . setView ( promptView ); final EditText input = ( EditText ) promptView . findViewById ( R . id . etCategory ); input . requestFocus (); input . setHint ( "Enter Category" ); input . setTextColor ( Color . BLACK ); alert . setPositiveButton ( "OK" , new DialogInterface . OnClickListener () { public void onClick ( DialogInterface dialog , int whichButton ) { String newCategoryName = input . getText (). toString (); // Do something with value! if ( newCategoryName . equals ( "" )) { input . setError ( ...