標籤: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樣本與說明