跳到主要内容
Version: 0.78

ToastAndroid

本模块将原生的 ToastAndroid 模块导出为一个 JS 模块,用于在 Android 设备上显示一个悬浮的提示信息。本模块包含一个show方法接受以下的参数:

  • message 一个字符串,表示将要显示的文本内容。
  • duration 提示信息持续显示的时间。可以是ToastAndroid.SHORT或者ToastAndroid.LONG

还有一个名为showWithGravity的方法可以指定弹出的位置。可选项有:ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER.

The 'showWithGravityAndOffset(message, duration, gravity, xOffset, yOffset)' method adds the ability to specify an offset with in pixels.

Imperative hack

The ToastAndroid API is imperative, but there is a way to expose a declarative component from it as in this example:


文档

方法

show()

React JSX
static show(message, duration)

showWithGravity()

React JSX
static showWithGravity(message, duration, gravity)

showWithGravityAndOffset()

React JSX
static showWithGravityAndOffset(message, duration, gravity, xOffset, yOffset)

属性

SHORT

Indicates the duration on the screen.

React JSX
ToastAndroid.SHORT;

LONG

Indicates the duration on the screen.

React JSX
ToastAndroid.LONG;

TOP

Indicates the position on the screen.

React JSX
ToastAndroid.TOP;

BOTTOM

Indicates the position on the screen.

React JSX
ToastAndroid.BOTTOM;

CENTER

Indicates the position on the screen.

React JSX
ToastAndroid.CENTER;