我是Android编程的新手,我一直在互联网上做很多教程,但我一直在讨论不推荐使用的方法,例如当我调用BitmapFactory.Options.inPurgeable时,android studio跨越inPurgeable,给出消息该方法已被弃用.
我在哪里可以找到弃用方法的替代方案?
当我尝试进行发行时,出现了这个问题。
Build.gradle文件
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.trevexs.sengaapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 5
versionName "1.5.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
versionNameSuffix "-DEBUG"
}
}
dataBinding {
enabled = true
}
testOptions {
unitTests {
returnDefaultValues = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: …Run Code Online (Sandbox Code Playgroud) static propTypes = {
// Value to display
value: PropTypes.string.isRequired,
// Wheter this values was chosen by user or not
isChosen: PropTypes.bool.isRequired,
// Gets called when user choses this value
onChoose: PropTypes.func.isRequired,
}
Run Code Online (Sandbox Code Playgroud)
为什么在定义上述 PropType 时要添加“.isRequired”?我是一个反应原生初学者
尝试使用笑话和酶测试我的本机应用程序,如下所示。
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import { SignUp } from '../../src/pages';
describe('Testing SignUp component', () => {
it('renders as expected', () => {
const wrapper = shallow(
<SignUp />
);
expect(wrapper).toMatchSnapshot();
});
});
Run Code Online (Sandbox Code Playgroud)
在运行npm test 我得到错误Cannot find module 'enzyme/build/ShallowTraversal' from 'shallow.js'
测试套件无法运行。
请注意,已完成测试的负酶正常运行
test('SignUp Page renders correctly', () => {
const tree = renderer.create(<SignUp />).toJSON();
expect(tree).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
有什么事吗
我正在尝试制作一个 TextInput,用户可以在其中输入最多四行的文本。当 textinput 现在自动滚动时,用户可以继续输入文本。
const InputNoLabel = ({ value, onChangeText, placeholder,
secureTextEntry, onContentSizeChange, height }) => {
const { inputStyle, containerStyle } = styles;
return (
<View style={containerStyle}>
<TextInput
underlineColorAndroid='transparent'
secureTextEntry={secureTextEntry}
placeholder={placeholder}
autoCorrect={false}
style={[inputStyle, { height }]} //height: height
value={value}
onChangeText={onChangeText}
onContentSizeChange={onContentSizeChange}
multiline={true}
editable={true}
/>
</View>
);
};
Run Code Online (Sandbox Code Playgroud)
onContentSizeChange 我手动更改容器的高度并传递一个新高度,但是当我达到最大高度时,我输入的任何更多文本都会被隐藏。
<View style={rowContainer}>
<InputNoLabel
label="Enter Text Here"
placeholder="Name"
onChangeText={this.onTextChange.bind(this)}
/* value={this.state.value} */
height={this.state.height}
onContentSizeChange={this.onContentSizeChange.bind(this)}
/>
</View >
onContentSizeChange() {
this.setState({
height: Math.max(48, this.state.height + 16)
});
}
Run Code Online (Sandbox Code Playgroud)
如何让 TextInput 将输入的行数调整为最大行数,但也允许更多的输入,但这次只滚动文本