[英]Programmatically changing textview in Linear Layout depending on user attributes
I want to programmatically change a textview depending whether or not an ArrayList is available. 我想以编程方式更改Textview,这取决于ArrayList是否可用。 Basically, I had three different RecyclerView Adapters & TextViews to display a user's pets, kids and cars. 基本上,我有三个不同的RecyclerView适配器和TextViews来显示用户的宠物,孩子和汽车。 If a person does not have one of these, I blank the RecyclerView and want to delete that textview and move everything up to replace it. 如果没有一个人,我将RecyclerView清空,并想删除该textview并向上移动所有内容以替换它。 1 : http://i.stack.imgur.com/2v1OM.png 1 : http : //i.stack.imgur.com/2v1OM.png
The only thing that has worked for me is to use TextView.setVisibility(View.GONE). 对我来说唯一有效的方法是使用TextView.setVisibility(View.GONE)。 But obviously, that doesn't work for me. 但显然,这对我不起作用。 I've tried this as suggested in a different question: 我已经按照另一个问题的建议进行了尝试:
LinearLayout lL = new LinearLayout(getContext());
lL.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Pets.setPadding(0, 0, 0, 0);
However, that doesn't work for me either in terms of pushing it up. 但是,就提高它而言,这对我都不起作用。
您可以尝试将RecyclerView
的可见性设置为View.GONE
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.