react native 中函数ToastAndroid示例与说明

阅读: 评论:0

react native 中函数ToastAndroid示例与说明

react native 中函数ToastAndroid示例与说明

/**
* 函数ToastAndroid(用于在Android设备上显示一个悬浮的提示信息)
* */

import React,{PureComponent} from 'react'
import {View,Text,TouchableOpacity,ToastAndroid} from 'react-native'

class VibrationFunction extends PureComponent {
render() {
return (
<View>
<TouchableOpacity
onPress={() => ToastAndroid.show('我是悬浮窗信息', 20000)}
style={{height:50,backgroundColor:'#0f0',borderRadius:30,marginTop:30,justifyContent:'center',alignItems:'center'}}
>
<View>
<Text style={{textAlign:'center'}}>悬浮的提示信息(ToastAndroid)</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={() => ToastAndroid.showWithGravity('我是悬浮窗信息',10000, ToastAndroid.LONG,ToastAndroid.TOP)}
style={{height:50,backgroundColor:'#0f0',borderRadius:30,marginTop:30,justifyContent:'center',alignItems:'center'}}
>
<View>
<Text style={{textAlign:'center'}}>悬浮的提示信息TOP(ToastAndroid)</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={() => ToastAndroid.showWithGravity('我是悬浮窗信息', ToastAndroid.SHORT,ToastAndroid.BOTTOM)}
style={{height:50,backgroundColor:'#0f0',borderRadius:30,marginTop:30,justifyContent:'center',alignItems:'center'}}
>
<View>
<Text style={{textAlign:'center'}}>悬浮的提示信息BOTTOM(ToastAndroid)</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={() => ToastAndroid.showWithGravity('我是悬浮窗信息', ToastAndroid.SHORT,ToastAndroid.CENTER)}
style={{height:50,backgroundColor:'#0f0',borderRadius:30,marginTop:30,justifyContent:'center',alignItems:'center'}}
>
<View>
<Text style={{textAlign:'center'}}>悬浮的提示信息CENTER(ToastAndroid)</Text>
</View>
</TouchableOpacity>
</View>
);
}
}
export default VibrationFunction;

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

String message: 一个字符串,表示将要显示的文本内容。
int duration: 提示信息持续显示的时间。可以是ToastAndroid.SHORT或者ToastAndroid.LONG。
还有一个名为showWithGravity的方法可以指定弹出的位置。可选项有:ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER.

用法示例:

//方法
static show(message: string, duration: number)
显示(消息:字符串,持续时间:数字)

static showWithGravity(message, duration, gravity)
showWithGravity(消息、持续时间、位置)

属性
SHORT: MemberExpression

LONG: MemberExpression

// 时间常数

TOP: MemberExpression
//顶部

BOTTOM: MemberExpression
//底部

CENTER: MemberExpression
//中间

/ /位置常数


* ***/
函数Share(用于在Android设备上打开一个对话框来分享或发送文本内容)

转载于:.html

本文发布于:2024-01-31 20:45:46,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170670514931239.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

下一篇:ant
标签:示例   函数   react   native   ToastAndroid
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23