react native 中函數ToastAndroid樣本與說明

來源:互聯網
上載者:User

標籤:ble   col   樣本   內容   一個   str   roi   class   margin   

/**
* 函數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裝置上開啟一個對話方塊來分享或發送常值內容)

react native 中函數ToastAndroid樣本與說明

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.