例如,我的列表视图中有50个项目。列表视图的项目包含问题,当用户单击该项目时,它将转到下一个活动并显示答案。那怎么能这样做呢。请建议我任何可能有帮助的想法
答案 0 :(得分:2)
在FirstActivity.java中
render() {
return (
<ListView
style={styles.container}
dataSource={this.props.dataSource}
renderRow={this._renderRow.bind(this)}
/>
)
}
在SecondActivity.java中
#wrapper {
position: relative;
background: url(http://planetbounce.m360.co.uk/wp-content/themes/planetbounce/assets/img/fabric-bg.png);
background-repeat: repeat;
z-index: 2;
width: 100%;
height: 2000px;
}
#wrapper:before {
content: '';
background: url(http://planetbounce.m360.co.uk/wp-content/themes/planetbounce/assets/img/trampology-left-bg.png) no-repeat;
background-size: contain;
display: block;
width: 20%;
height: 100%;
position: absolute;
left: 0;
top:0;
}
#wrapper:after {
content: "";
background: url(http://planetbounce.m360.co.uk/wp-content/themes/planetbounce/assets/img/trampology-right-bg.png) no-repeat;
background-size: contain;
display: block;
width: 20%;
height: 100%;
position: absolute;
right: 0;
top: 0;
z-index: 10
}
根据所选问题ID显示答案。
答案 1 :(得分:0)
为了使列表可以点击,请应用setOnItemClickListener
。
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listView, View view,
int position, long id) {
Intent intent = new Intent(YourCurrentActivity.this, NextActivity.class);
startActivity(intent);
});