Clase PickerBuilder
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
PickerBuilder
se usa para crear objetos Picker
. Excepto que se indique lo contrario, el tipo de datos que se muestra a continuación es de tipo PickerBuilder
, lo que te permite encadenar una llamada después de otra.
Ejemplos
Compila un Picker
básico con el patrón de generador.
const picker = new google.pickerPickerBuilder()
.setOAuthToken('TOKEN_FOR_USER')
.setAppId('1234567890') // Cloud Project number
.addView(google.picker.ViewId.DOCS)
.setCallback((data) => {
console.log(data);
})
.build();
Firma
export class PickerBuilder
Detalles
Métodos
Nombre |
Descripción |
addView(viewOrViewId) |
Agrega una vista al panel de navegación. |
addViewGroup(viewGroup) |
Agrega un ViewGroup al panel de navegación de nivel superior. |
build() |
Construye el objeto Selector. |
disableFeature(feature) |
Inhabilitar una función de selector |
enableFeature(feature) |
Habilita una función de selector. |
getRelayUrl() |
Obtén la URL de retransmisión, que se usa para gadgets.rpc. |
getTitle() |
Obtén el título del diálogo. |
hideTitleBar() |
Inhabilitar la barra de título para que no se muestre Para volver a habilitarlo, llama a setTitle con un título no vacío o undefined . |
isFeatureEnabled(feature) |
Verifica si el selector Feature está habilitado. |
setAppId(appId) |
Establece el ID de la aplicación que necesita acceder a los archivos del usuario a través de Drive API . |
setCallback(method) |
Establece el método de devolución de llamada. Se llama a este método cuando el usuario selecciona elementos o cancela. El método de devolución de llamada recibe un solo objeto de devolución de llamada. La estructura del objeto de devolución de llamada se describe en la Guía de JSON. |
setDeveloperKey(key) |
Establece la clave de la API del navegador obtenida de Google Play Console. Consulta la Guía para desarrolladores para obtener detalles sobre cómo obtener la clave de la API del navegador. |
setDocument(document) |
Configura el documento. |
setLocale(locale) |
Establece la configuración regional del selector. La configuración regional es un código de idioma ISO 639. Si el idioma no es compatible, se usa en-US. |
setMaxItems(max) |
Establece la cantidad máxima de elementos que puede elegir un usuario. |
setOAuthToken(token) |
Establece un token de OAuth para usar en la autenticación del usuario actual. |
setOrigin(origin) |
Establece el origen del diálogo del selector. Si la aplicación se ejecuta en un iframe, el origen se debe establecer en window.location.protocol + '//' + window.location.host. |
setRelayUrl(url) |
Establece la URL de retransmisión que se usa para gadgets.rpc. |
setSelectableMimeTypes(type) |
Establece la lista de tipos de MIME que se podrán seleccionar. Usa comas para separar los tipos de MIME si se requiere más de uno. Si no configuras los tipos MIME, se mostrarán en la vista archivos de todos los tipos MIME. |
setSize(width, height) |
Establece el tamaño de diálogo preferido. El diálogo se centrará automáticamente. Tiene un tamaño mínimo de (566,350) y un tamaño máximo de (1051,650). |
setTitle(title) |
Establece el título del diálogo. |
toUri() |
Muestra el URI que generó este compilador. |
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-25 (UTC)
[null,null,["Última actualización: 2025-07-25 (UTC)"],[],[],null,["# Class PickerBuilder\n\n`PickerBuilder` is used to create `Picker` objects. Except where noted\notherwise, the return type of methods below is of type `PickerBuilder`, allowing\nyou to chain one call after another.\n\nExamples\n--------\n\nBuild a basic `Picker` using the builder pattern. \n\n const picker = new google.pickerPickerBuilder()\n .setOAuthToken('TOKEN_FOR_USER')\n .setAppId('1234567890') // Cloud Project number\n .addView(google.picker.ViewId.DOCS)\n .setCallback((data) =\u003e {\n console.log(data);\n })\n .build();\n\nSignature\n---------\n\n export class PickerBuilder\n\nDetails\n-------\n\n| Final | No |\n|-------|----|\n\nMethods\n-------\n\n| Name | Description |\n|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`addView(viewOrViewId)`](./picker.pickerbuilder.addview) | Add a view to the navigation pane. |\n| [`addViewGroup(viewGroup)`](./picker.pickerbuilder.addviewgroup) | Add a ViewGroup to the top-level navigation pane. |\n| [`build()`](./picker.pickerbuilder.build) | Construct the Picker object. |\n| [`disableFeature(feature)`](./picker.pickerbuilder.disablefeature) | Disable a picker feature. |\n| [`enableFeature(feature)`](./picker.pickerbuilder.enablefeature) | Enable a picker feature. |\n| [`getRelayUrl()`](./picker.pickerbuilder.getrelayurl) | Get the relay URL, used for gadgets.rpc. |\n| [`getTitle()`](./picker.pickerbuilder.gettitle) | Get the dialog title. |\n| [`hideTitleBar()`](./picker.pickerbuilder.hidetitlebar) | Disable the title bar from being shown. To re-enable, call `setTitle` with a non-empty title or `undefined`. |\n| [`isFeatureEnabled(feature)`](./picker.pickerbuilder.isfeatureenabled) | Check if a picker `Feature` is enabled. |\n| [`setAppId(appId)`](./picker.pickerbuilder.setappid) | Sets the Id of the application needing to access the user's files via the [`Drive API`](/workspace/drive/api). |\n| [`setCallback(method)`](./picker.pickerbuilder.setcallback) | Set the callback method. This method is called when the user selects items or cancels. The callback method receives a single callback object. The structure of the callback object is described in the [JSON Guide](/workspace/drive/picker/reference/results). |\n| [`setDeveloperKey(key)`](./picker.pickerbuilder.setdeveloperkey) | Sets the Browser API key obtained from Google Developers Console. See the Developer's Guide for details on how to obtain the Browser API key. |\n| [`setDocument(document)`](./picker.pickerbuilder.setdocument) | Set the document. |\n| [`setLocale(locale)`](./picker.pickerbuilder.setlocale) | Set the locale for the picker. The locale is an ISO 639 language code. If the language is not supported, en-US is used. |\n| [`setMaxItems(max)`](./picker.pickerbuilder.setmaxitems) | Sets the maximum number of items a user can pick. |\n| [`setOAuthToken(token)`](./picker.pickerbuilder.setoauthtoken) | Sets an OAuth token to use for authenticating the current user. |\n| [`setOrigin(origin)`](./picker.pickerbuilder.setorigin) | Sets the origin of picker dialog. The origin should be set to the window.location.protocol + '//' + window.location.host of the top-most page, if your application is running in an iframe. |\n| [`setRelayUrl(url)`](./picker.pickerbuilder.setrelayurl) | Set the relay URL, used for gadgets.rpc. |\n| [`setSelectableMimeTypes(type)`](./picker.pickerbuilder.setselectablemimetypes) | Set the list of MIME types which will be selectable. Use commas to separate MIME types if more than one is required. If you don't set MIME types, files of all MIME types are displayed in the view. |\n| [`setSize(width, height)`](./picker.pickerbuilder.setsize) | Set the preferred dialog size. The dialog will be auto-centered. It has a minimum size of (566,350) and a maximum size of (1051,650). |\n| [`setTitle(title)`](./picker.pickerbuilder.settitle) | Set the dialog title. |\n| [`toUri()`](./picker.pickerbuilder.touri) | Returns the URI generated by this builder. |"]]