src/com/example/knitknit/ProjectList.java
private void showNameDialog(final long projectID, String currentName) {
		// Instantiate a view of projectlist_namedialog.xml
		LayoutInflater inflater = (LayoutInflater)
			this.getSystemService(LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.projectlist_namedialog,
			null, false);

		// Find the name EditText field
		final EditText name = (EditText)
			view.findViewById(R.id.projectlist_namedialog_name);

		// If we are renaming, put the current name in the box
		if (currentName != null) {
			name.append(currentName);
		}

		DialogInterface.OnClickListener listener =
			new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				if (projectID == -1) {
					mDatabaseHelper.insertProject(
						name.getText().toString());
					fillList();
				} else {
					mDatabaseHelper.renameProject(
						projectID,
						name.getText().toString());
				}
				return;
			}
			};

		// Create an AlertDialog and set its attributes
		AlertDialog.Builder nameDialog =
			new AlertDialog.Builder(this);
		nameDialog.setCancelable(true);
		nameDialog.setTitle(
			(projectID == -1 ?
			R.string.projectlist_namedialog_title_create :
			R.string.projectlist_namedialog_title_rename));
		nameDialog.setPositiveButton(
			(projectID == -1 ?
				R.string.projectlist_namedialog_create :
				R.string.projectlist_namedialog_rename),
			listener);

		// Fill the dialog with the view
		nameDialog.setView(view);
		nameDialog.create();

		// Show the dialog
		nameDialog.show();
	}
//	-If >= 0, we are renaming the project with this projectID
If >= 0, we are renaming the project with this projectID
If > = 0 we are renaming the project with this projectID
private void showNameDialog(final long projectID, String currentName) {
		LayoutInflater inflater = (LayoutInflater)
			this.getSystemService(LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.projectlist_namedialog,
			null, false);
		final EditText name = (EditText)
			view.findViewById(R.id.projectlist_namedialog_name);
		if (currentName != null) {
			name.append(currentName);
		}
		DialogInterface.OnClickListener listener =
			new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				if (projectID == -1) {
					mDatabaseHelper.insertProject(
						name.getText().toString());
					fillList();
				} else {
					mDatabaseHelper.renameProject(
						projectID,
						name.getText().toString());
				}
				return;
			}
			};
		AlertDialog.Builder nameDialog =
			new AlertDialog.Builder(this);
		nameDialog.setCancelable(true);
		nameDialog.setTitle(
			(projectID == -1 ?
			R.string.projectlist_namedialog_title_create :
			R.string.projectlist_namedialog_title_rename));
		nameDialog.setPositiveButton(
			(projectID == -1 ?
				R.string.projectlist_namedialog_create :
				R.string.projectlist_namedialog_rename),
			listener);
		nameDialog.setView(view);
		nameDialog.create();
		nameDialog.show();
	}
private void showNameDialog ( final long projectID , String currentName ) { LayoutInflater inflater = ( LayoutInflater ) this . getSystemService ( LAYOUT_INFLATER_SERVICE ) ; View view = inflater . inflate ( R . layout . projectlist_namedialog , null , false ) ; final EditText name = ( EditText ) view . findViewById ( R . id . projectlist_namedialog_name ) ; if ( currentName != null ) { name . append ( currentName ) ; } DialogInterface . OnClickListener listener = new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { if ( projectID == - 1 ) { mDatabaseHelper . insertProject ( name . getText ( ) . toString ( ) ) ; fillList ( ) ; } else { mDatabaseHelper . renameProject ( projectID , name . getText ( ) . toString ( ) ) ; } return ; } } ; AlertDialog . Builder nameDialog = new AlertDialog . Builder ( this ) ; nameDialog . setCancelable ( true ) ; nameDialog . setTitle ( ( projectID == - 1 ? R . string . projectlist_namedialog_title_create : R . string . projectlist_namedialog_title_rename ) ) ; nameDialog . setPositiveButton ( ( projectID == - 1 ? R . string . projectlist_namedialog_create : R . string . projectlist_namedialog_rename ) , listener ) ; nameDialog . setView ( view ) ; nameDialog . create ( ) ; nameDialog . show ( ) ; }
If >= 0, we are renaming the project with this projectID
If > = 0 we are renaming the project with this projectID
// Instantiate a view of projectlist_namedialog.xml // Find the name EditText field // If we are renaming, put the current name in the box // Create an AlertDialog and set its attributes // Fill the dialog with the view // Show the dialog