当从 API 接收到响应时,这假设是一个滚动视图,其中包含从 Java 代码添加的所有内容。
问题是我找不到在ScrollView
. 我尝试使用 aImageButton
但我无法获取其中的内容然后我尝试使用 aButton
但仍然无法达到预期的效果请有人建议我可以这样做的方法。
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;
}
您应该使用RecyclerView。RecyclerView 中的每个组件都是CardView。你也应该学习材料设计。
除了以上一些有用的链接:https : //developer.android.com/guide/topics/ui/layout/cardview.html https://www.androidhive.info/2016/01/android-working-with-recycler -view/ https://medium.com/@nileshsingh/android-cardview-101-everything-you-should-know-5bbf1c873f5a
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句