在我的应用程序需要抽屉导航,我使用示例代码此.我已将所有内容集成到我的应用程序中,但收到以下错误
undefined不是函数(评估'(0,_reactNavigation.stacknavigator)')
并安装了这个.
npm install react-navigation --save
但不知道为什么会出现这个错误,所以请指导我如何解决这个问题.
这是我的app.js.
import React, { Component } from 'react';
import { StyleSheet , Platform , View , Text , Image ,
TouchableOpacity , YellowBox } from 'react-native';
import { DrawerNavigator, StackNavigator } from 'react-navigation';
class NavigationDrawerStructure extends Component {
//Structure for the navigatin Drawer
toggleDrawer = () => {
//Props to open/close the drawer
this.props.navigationProps.toggleDrawer();
};
render() {
return (
<View style={{ flexDirection: 'row' }}>
<TouchableOpacity onPress={this.toggleDrawer.bind(this)}>
{/*Donute Button Image */} …Run Code Online (Sandbox Code Playgroud) 大家好我正在使用带编辑文本的警告对话框.所以我想以编程方式将输入类型设置为编辑文本的密码.我在谷歌搜索了很多并找出这两种方法:
final EditText input = new EditText(getActivity());
input.setTransformationMethod(PasswordTransformationMethod.getInstance());
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
Run Code Online (Sandbox Code Playgroud)
但它不适合我,它显示文本.但我想要点缀文字.我不知道的问题是什么.所以请建议我做.感谢所有提前.这是带编辑文本的对话框代码:
public void showDialog(){
/* Alert Dialog Code Start*/
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
// alert.setTitle("JPOP"); //Set Alert dialog title here
alert.setMessage(" Please enter password"); //Message here
Log.e("dialog in password ","passworddddddddddddddddd");
// Set an EditText view to get user input
final EditText input = new EditText(getActivity());
// input.setInputType(InputType.TYPE_CLASS_TEXT);
// input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
// input.setTransformationMethod(PasswordTransformationMethod.getInstance());
// final EditText input = new EditText(getActivity());
input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
input.setTransformationMethod(new PasswordTransformationMethod());
input.setHint("Password");
input.setSingleLine();
input.setTextSize(14);
alert.setView(input);
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想从中选择图像Gallery并设置图像ListView.在我的ListView I have 16 rows. So when ever item click inListView open the gallery and set the image toListView中,. But my problem is some times afterstartActivityForResult(),oncreate()`方法被调用.这是onclick代码
Intent intent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(
Intent.createChooser(intent, "Select File"),
SELECT_PICTURE);
Run Code Online (Sandbox Code Playgroud)
这是一个非常活跃的结果
public void onActivityResult(int requestcode, int resultcode, Intent data) {
Log.e("result", "result");
displayMetrics = this.getResources().getDisplayMetrics();
Ew = displayMetrics.widthPixels;
Eh = displayMetrics.heightPixels;
switch (requestcode) {
case SELECT_PICTURE:
if (resultcode == RESULT_OK) { …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想在imageview上用手指画线.我希望输出如下:
在此屏幕中,fish是imageview,红线是绘制线条.所以我按照下面的链接开发应用程序 链接.这是我的代码:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.addphoto);
btnAddPhoto=(Button)findViewById(R.id.add);
btnEdit=(Button)findViewById(R.id.edit);
imageView=(ImageView)findViewById(R.id.photo);
btnAddPhoto.setOnClickListener(this);
btnEdit.setOnClickListener(this);
imageView.setOnTouchListener(this);
}
@Override
public void onWindowFocusChanged(boolean hasFocus){
width=imageView.getWidth();
height=imageView.getHeight();
Log.e("heightttt",""+height);
Log.e("Widthhhh",""+width);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.equals(btnAddPhoto)){
popup.setVisibility(View.VISIBLE);
}
if(v.equals(btnEdit)){
bitmap = Bitmap.createBitmap((int) width, (int) height,Bitmap.Config.ARGB_8888);
canvas = new Canvas(bitmap);
paint = new Paint();
paint.setColor(Color.BLACK);
imageView.setImageBitmap(bitmap);
imageView.setOnTouchListener(this);
}
}
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
downx = event.getX(); …Run Code Online (Sandbox Code Playgroud) 我是 React 原生开发的新手。在我的应用程序中,我有登录页面,在此登录页面中有两个文本输入。在此文本输入中没有下划线。我尝试了很多方法,但没有下划线。这里我的要求是需要输入文本的下划线。那么如何得到这个下划线呢?
这是我的登录表单代码。
import React, {Component} from 'react';
import {StyleSheet, Text, View,TextInput,TouchableOpacity} from 'react-native';
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>SEDC</Text>
<TextInput placeholder="Acct No/User Id" style={styles.textInput} multiline={true}></TextInput>
<TextInput placeholder="Password" style={styles.textInput}></TextInput>
<TouchableOpacity style={styles.btn} onPress={this.login}><Text>Log In</Text></TouchableOpacity>
</View>
);
}
login=()=>{
alert("testing......");
// this.props.navigation.navigate('Second');
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
textInput: {
alignSelf: 'stretch', …Run Code Online (Sandbox Code Playgroud) 我是新来响应本地开发的人。在一个屏幕上的应用程序中,我单击了图像。因此,我在可触摸的不透明度内拍摄了图像,并为该可触摸的不透明度写了onpress方法。但是onpress无法正常工作。但是我已经将相同的代码写到了另一张图像,但是这个正在工作。
这是代码
mport React, {Component} from 'react';
import {Text, View,TouchableHighlight,TouchableOpacity,StyleSheet,StatusBar,Image} from 'react-native';
export default class Profile extends Component {
static navigationOptions = ({ navigation }) => {
return {
title: `Welcome`,
header: null,
}
};
render() {
const { state, navigate } = this.props.navigation;
return (
<View style={styles.MainContainer}>
<StatusBar
barStyle="light-content"
backgroundColor="#2f5597"
/>
<View style={{backgroundColor: "#fff",padding: 10}}>
<Image source={require('../../app/images/ic_visa.png')} style={{marginLeft: -10}}></Image>
<TouchableOpacity onPress={() => this.backArrow()} style={styles.signoutContainer}>
<Image source={require('../../app/images/ic_Signout.png')} style={styles.signOutImage}></Image>
</TouchableOpacity>
</View>
<View style={{backgroundColor: "#2f5597",flexDirection: 'row',alignItems: 'center'}}>
<TouchableOpacity onPress={() => this.backArrow()} style={{padding: …Run Code Online (Sandbox Code Playgroud) 我是对原生开发做出反应的新手。在我的应用程序中,我需要调用soap web 服务。在android中,我将ksoap库用于soap web服务。但是在 React Native 中是否有任何可用的库或任何示例代码?我为此搜索了很多,但没有找到任何关于此的好的样本。
我发现了以下样品
https://www.npmjs.com/package/soap-everywhere
https://github.com/adamski/react-native-soap-request
但是在这个样本中没有清晰和正确的解释。所以请指导我如何做到这一点
提前致谢
我正在开发流媒体应用程序,因此我正在使用 exoplayer。这是代码。它一切正常。但我需要显示通知以及标题和播放/暂停按钮。这个播放/暂停按钮必须像活动播放/暂停按钮一样工作,这个播放/暂停按钮必须根据播放/暂停而改变。
public class MainActivity extends AppCompatActivity {
private SimpleExoPlayer exoPlayer;
private ExoPlayer.EventListener eventListener = new ExoPlayer.EventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
Log.i(TAG,"onTimelineChanged");
}
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
Log.i(TAG,"onTracksChanged");
}
@Override
public void onLoadingChanged(boolean isLoading) {
Log.i(TAG,"onLoadingChanged");
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
Log.i(TAG,"onPlayerStateChanged: playWhenReady = "+String.valueOf(playWhenReady)
+" playbackState = "+playbackState);
switch (playbackState){
case ExoPlayer.STATE_ENDED:
Log.i(TAG,"Playback ended!");
//Stop playback and return to start position
setPlayPause(false);
exoPlayer.seekTo(0);
break;
case ExoPlayer.STATE_READY: …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想更改ImageView,如下所示.我只想改变身体上的图像.

我已按照以下链接使用类似的代码更改alpha值
imageView.setAlpha(255);
Run Code Online (Sandbox Code Playgroud)
但它没有用.
如何在Android中为View设置不透明度(Alpha).请有人建议我怎么做.
在我的项目中,我有一些线性布局的复选框.默认情况下运行项目时,所有复选框都未选中,我需要选中一些复选框.复选框下方有一个重置按钮.单击重置按钮时,将取消选中所有复选框.我该怎么做呢?请帮忙.
我是本机反应新手,我创建了一个示例登录表单。在这种形式中,我想将总视图对齐到中心。我尝试了这种方法但不起作用,你能指导我如何实现这一目标吗?
我的登录类是
import React, {Component} from 'react';
import {AppRegistry,Text, View,TextInput,TouchableOpacity,StyleSheet} from 'react-native';
export default class Login extends Component{
render(){
return(
<View style={styles.container}>
<TextInput style={styles.textInput} placeholder="Acc No/User ID"/>
<TextInput style={styles.textInput} placeholder="Password"/>
<TouchableOpacity style={styles.btn} onPress={this.login}><Text>Log In</Text></TouchableOpacity>
</View>
);
}
login=()=>{
alert("testing......");
// this.props.navigation.navigate('Second');
}
}
AppRegistry.registerComponent('Login', () => Login);
const styles = StyleSheet.create({
container:{
justifyContent: 'center',
alignItems: 'center',
},
header: {
fontSize: 24,
marginBottom: 60,
color: '#fff',
fontWeight: 'bold',
},
textInput: {
alignSelf: 'stretch',
padding: 10,
marginLeft: 80,
marginRight:80,
},
btn:{
alignSelf: …Run Code Online (Sandbox Code Playgroud) 我是对原生开发做出反应的新手。在我的应用程序中,我需要根据条件更改视图的颜色。所以我的问题是我可以在 react native 中的视图之间使用 if 条件吗?以下是代码
import React, {Component} from 'react';
import {StyleSheet, FlatList, Text, View, Alert,Image,TouchableOpacity} from 'react-native';
export default class Myproject extends Component {
constructor(props)
{
super(props);
this.state = { FlatListItems: [
{key: 'One'},
{key: 'Two'},
{key: 'Three'},
{key: 'Four'},
{key: 'Five'},
{key: 'Six'},
{key: 'Seven'},
{key: 'Eight'},
{key: 'Nine'},
{key: 'Ten'},
{key: 'Eleven'},
{key: 'Twelve'}
]}
}
FlatListItemSeparator = () => {
return (
<View
style={{
height: 1,
width: "100%",
marginLeft: 12,
backgroundColor: "#607D8B",
}}
/>
); …Run Code Online (Sandbox Code Playgroud) android ×6
react-native ×6
image ×2
alpha ×1
checkbox ×1
drawing ×1
exoplayer ×1
if-statement ×1
imageview ×1
onpress ×1
soap ×1
textinput ×1
view ×1
web-services ×1