zoukankan      html  css  js  c++  java
  • 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设备上打开一个对话框来分享或发送文本内容)
  • 相关阅读:
    linux常用命令---文件操作
    Django 框架中定时触发脚本
    jquery 中选择当前标签下众多相同子标签中的第n个
    Django + DRF + Elasticsearch 实现搜索功能
    django 使用celery 实现异步任务
    python 通过 pymysql模块 操作 mysql 数据库
    django 自定义中间件 middleware
    django 使用其自带的验证系统 进行用户名有效性验证 登录状态验证 登入操作 登出操作
    python脚本 读取excel格式文件 并进行处理的方法
    python 将json格式的数据写入csv格式的文件中
  • 原文地址:https://www.cnblogs.com/zhuyupingit/p/7667928.html
Copyright © 2011-2022 走看看