简体   繁体   中英

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. Basically, I had three different RecyclerView Adapters & TextViews to display a user's pets, kids and cars. 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. 1 : http://i.stack.imgur.com/2v1OM.png

文字检视

The only thing that has worked for me is to use 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM