日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

React Native Android随笔日记

發(fā)布時間:2024/3/12 Android 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 React Native Android随笔日记 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、以前做Listview 的時候都會有一個滾動條,不由分說,很丑,以前想要去掉卻無從下手,

今日偶然發(fā)現(xiàn)Scrollview有兩個屬性

showsHorizontalScrollIndicator bool

當此屬性為true的時候,顯示一個水平方向的滾動條。

showsVerticalScrollIndicator bool

當此屬性為true的時候,顯示一個垂直方向的滾動條。

一定要記得試一下。果然有用,驗證成功。

2、一些簡潔的代碼語法老會忘記怎么寫,現(xiàn)發(fā)現(xiàn)一條就記錄一條

<View style={[styles.innerContainer, {marginBottom:47}]}></View> <Text style={{color:'red'}}>{this.state.second>=0?this.state.second:'重發(fā)驗證碼'}</Text> <Text style={this.state.selectstate==0?styles.presstextnianfen:styles.textnianfen}>全部</Text> <Image source={rowData.currentscore>1?require('../home/icon_star_yellow.png'):require('../home/icon_star_grey.png')}style={{width:15,height:15,marginRight:2}}/>

?

<View style={{width:150,height:150,backgroundColor:this.state.selectcenterstate[rowID]==0? "#E9E6E6":"#D2EDF6",borderRadius:5,flexDirection:'column'}}>

?3、關于如何在pop頁面后觸動更新的問題

一個很好的解決辦法從A頁面push到B頁面,傳一個刷新的函數(shù)過去,這樣從B頁面pop回A頁面的同時,調用該函數(shù)。

例如A頁面代碼:回調函數(shù)中傳一個刷新的函數(shù)fetchstorise()

pusheditcenter(talkmsg){let _this = this;this.props.navigator.push({name:'editcenter',component:TrainerselfCenterEdit,params:{talkmsg:talkmsg,getparams: function(){_this.fetchStories();}}}) }

B頁面代碼,在pop的時候調用該回調函數(shù)

pushback(){const { navigator } = this.props;if(this.props.getparams) {this.props.getparams();}if(navigator) { //出棧,返回到上一頁navigator.pop(); } }

?4、關于如何使用定時器

寫這個的原因是因為RN的發(fā)展速度過快,語法變,使用方法也相應改變,現(xiàn)在這里使用最新的es6的語法

componentDidMount(){this.timer=setTimeout(()=>{this.setState({content:'這是定時器打印的內容' })},2000); this.timer_two=setTimeout( ()=>{ this.setState({msg:'這是定時器打印的第二段內容'}) },4000 ); } componentWillUnmount(){ this.timer&&clearTimeout(this.timer); this.timer_two&&clearTimeout(this.timer_two); } render() { return ( <View style={{margin:20}}> <Text>{this.state.content}</Text> <Text>{this.state.msg}</Text> </View> ); }

注意:定時器功能比較簡單,注意在es6中使用時,需銘記在unmount組件時清除(clearTimeout/clearInterval)所有用到的定時器。

5、關于如何將ActivityIndicator與定時器結合使用

ActivityIndicator就是一個圓形的顯示指示器

屬性如下:

animating (bool)?

是否要顯示指示器,默認為true,表示顯示。

color (string)

滾輪的前景顏色(默認為灰色)。

size?enum('small', 'large')?

指示器的大小。small的高度為20,large為36。

實現(xiàn)大概思路:將是否顯示指示器anitmating屬性從false變成true的過程中通過定時器延遲幾秒。

constructor(props) {super(props);this.state = {loading: true};}componentDidMount() {this.timer = setTimeout(() => {this.setState({loading: false})},6000)}componentWillUnMount() {this.timer && clearTimeout(this.timer)}render() {return (<ActivityIndicatorsize='large'animating={this.state.loading}/> )}

?

轉載于:https://www.cnblogs.com/lgp142332/p/6096753.html

總結

以上是生活随笔為你收集整理的React Native Android随笔日记的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。