【发布时间】:2018-04-03 07:02:46
【问题描述】:
这应该是一个滚动视图,当从 API 收到响应时,所有内容都从 Java 代码中添加。
问题是我找不到在ScrollView 中显示此类信息的方法。我尝试使用ImageButton,但无法获取其中的内容,然后我尝试使用Button,但仍然无法达到预期的效果,请有人建议我可以做到这一点的方法。
private Button makeButton(String targetName, final String i, LinearLayout.LayoutParams buttonLayoutParams) {
Button in = new Button(this);
in.setBackground(getResources().getDrawable(R.drawable.rectangle14));
in.setText(targetName);
in.setWidth(360);
in.setHeight(72);
in.setLayoutParams(buttonLayoutParams);
in.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(HomeActivity.this,XSavingDetailsActivity.class);
myIntent.putExtra("i" ,i);
HomeActivity.this.startActivity(myIntent);
}
});
return in;
}
【问题讨论】:
-
您应该使用
ListView或RecyclerView
标签: java android android-layout android-studio scrollview