加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React Native Android

发布时间:2020-12-15 05:16:09 所属栏目:百科 来源:网络整理
导读:span style="font-family: Arial,Helvetica,sans-serif;"/**/span * Sample React Native App * https://github.com/facebook/react-native * @flow */import React,{ Component } from 'react';import { AppRegistry,StyleSheet,Text,Image,View} from 'rea
<span style="font-family: Arial,Helvetica,sans-serif;">/**</span>
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React,{ Component } from 'react';
import {
  AppRegistry,StyleSheet,Text,Image,View
} from 'react-native';


var MOCKED_MOVIES_DATA = [
  {title: 'Title',year: '2015',posters: {thumbnail: 'http://img1.cache.netease.com/ent/2015/8/4/20150804081025eb75c.jpg'}},];

class SampleApp extends Component {
  render() {
    var movie = MOCKED_MOVIES_DATA[0];
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          {movie.title+movie.year}
        </Text>
        <Text style={styles.instructions}>
          To get started,edit index.android.js
        </Text>

            <Text style={styles.instructions} onPress={onClick}>
                Shake or press menu button for dev menu
            </Text>
            <Image
                source={{uri: movie.posters.thumbnail}}
                style = {styles.imagestyle}
            />

      </View>
    );
  }
}

function onClick(){
   var ToastAndroid = require('ToastAndroid')
   ToastAndroid.show('Awesome,Clicking!',ToastAndroid.SHORT);
   console.log('pressed')
}
const styles = StyleSheet.create({
  container: {
    flex: 1,justifyContent: 'center',//
    alignItems: 'center',backgroundColor: '#F5FCFF',},btn:{
        width:50,backgroundColor:'#0091FF',justifyContent:'center',alignItems:'center'
      },welcome: {
    fontSize: 20,textAlign: 'center',margin: 10,instructions: {
    textAlign: 'center',color: '#333333',marginBottom: 5,style_view_button:{
      marginTop:15,marginLeft:10,marginRight:10,backgroundColor:'#63B8FF',borderColor:'#5bc0de',height:45,width:50,borderRadius:5,alignItems: 'center',imagestyle: {
    width: 100,height:100,});

AppRegistry.registerComponent('SampleApp',() => SampleApp);


rn 的android 教程我找了很久也没找到全面/细致 一些的教程,真是苦恼,摸着石头过河真的很辛苦。可能还没兴起,所以教程比较少,不过这就是我的乐趣所在。

ps:虽然做了将近2年android,但是因为一点js基础都没有,做rn 太吃力,今天实现了显示image 和 toast,乐的不行。。。。。。。。。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读