How to add multiple textviews in android - android

I am making one chat application in this application I have to display all users names who are connected to login user,so I am showing this data in dialog,actually problem is different text views with different styles in relative layout which wiil be arranged automatically side by side,if layout width occupied by 3 text views remaining two text views should be in third line like that.please help me
ex:
car bus bicycle
train ship bike
aeroplane

Try this:
<LinearLayout
android:id="#+id/categoriesContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#color/view_background"
android:orientation="vertical" >
<TextView
android:id="#+id/tagsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:text="#string/title"
android:textColor="#color/view_title"
android:textSize="18sp" />
<LinearLayout
android:id="#+id/tagsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:gravity="left"
android:orientation="vertical" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal"
android:padding="2dp" >
<Button
android:id="#+id/categoryIndications"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:background="#drawable/xml_category_count_bubble"
android:enabled="false"
android:minWidth="20dp"
android:padding="4dip"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
<Button
android:id="#+id/categoryName"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:background="#drawable/xml_category_name_bubble"
android:enabled="false"
android:minWidth="40dp"
android:padding="4dip"
android:textColor="#color/view_text"
android:textSize="14sp" />
And this:
private void setTags(){
LinearLayout tagsContainer;
// Categories
tagsContainer = (LinearLayout) rootView.findViewById(R.id.tagsContainer);
// Container of the tags
tagsContainer.removeAllViews();
tagsContainer.refreshDrawableState();
// Indicate category layout
LinearLayout indicateLayout = (LinearLayout)
LayoutInflater.from(getActivity().getApplicationContext()).
inflate(R.layout.message_indicate_category, null);
if(YOUR_TEXTVIEW_STRINGS_ARRAY.size()>0){
Button textButton;
LinearLayout tag;
for(int i = 0; i<YOUR_TEXTVIEW_STRINGS_ARRAY.size();i++){
// View of the tag
tag = (LinearLayout)
LayoutInflater.from(getActivity().getApplicationContext()).
inflate(R.layout.customview_tag, null);
textButton= (Button)tag.findViewById(R.id.categoryName);
textButton.setText(YOUR_TEXTVIEW_STRINGS_ARRAY..get(i));
textButton = (Button)tag.findViewById(R.id.categoryIndications);
textButton.setText(YOUR_TEXTVIEW_STRINGS_ARRAY.get(i));
tagsContainer.addView(tag);
}
}
else{
// View of the tag
indicateLayout = (LinearLayout)
LayoutInflater.from(getActivity().getApplicationContext()).
inflate(R.layout.message_indicate_category, null);
tagsContainer.addView(indicateLayout);
}
}

Related

How to fill layout by including another layouts in code?

I have layouts which will be repetitive added in main layout:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/txt_temp_feels_like"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-medium"
android:text="-"
android:textColor="#color/gray"
android:textSize="18sp" />
I want it to be added to this container:
<LinearLayout
android:id="#+id/temp_feels_like_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
</LinearLayout>
And I want to do it in code. I'm using this method:
private fun setData(
layout: List<Int>,
container: List<ViewGroup>,
) {
for (i in layout.indices) {
container[i].addView(layoutInflater.inflate(layout[i], null))
}
}
where layout is link to resource of layout.
And it's fill it but i have some problems:
I can't set text to this added view
I can't set weight to this view
Maybe my algorithm is wrong. Can you help?
It depends on when should you set the text and gravity. If you can set it before adding to layout - you can do something like that:
val view = layoutInflater.inflate(layout[i], null) as TextView
view.apply {
text = "abc"
params = (params as LinearLayout.LayoutParams).apply {
weight = *value you need*
}
}
container[i].addView(view)
Or if you need to set text to view after views are added to layout, you can reference to view via container.children/container.getChildAt(i)
UPD
you can get the child in the following way:
val count = layout.getChildCount()
var v: TextView? = null
for (i in 0..count) {
val view = layout.getChildAt(i)
if (view is TextView) {
v = view
}
}
Or one more way - set tag to view while adding it to layout and then you can get it by tag in any time you need
Could something like this help?
<LinearLayout
android:id="#+id/temp_feels_like_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:orientation="horizontal"
>
<TextView
android:id="#+id/txt_temp_feels_like1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-medium"
android:visibility="gone"
android:text="-"
android:textColor="#color/gray"
android:textSize="18sp"
/>
<TextView
android:id="#+id/txt_temp_feels_like2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-medium"
android:visibility="gone"
android:text="-"
android:textColor="#color/gray"
android:textSize="18sp"
/>
<TextView
android:id="#+id/txt_temp_feels_like3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-medium"
android:visibility="gone"
android:text="-"
android:textColor="#color/gray"
android:textSize="18sp"
/>
<TextView
android:id="#+id/txt_temp_feels_like4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-medium"
android:visibility="gone"
android:text="-"
android:textColor="#color/gray"
android:textSize="18sp"
/>
</LinearLayout>
You can have the gravity set appropriately (and the text if it's not dynamic),
and then set the visibility in code rather than try to add the view.
findViewById<View>(R.id.txt_temp_feels_like1).visibility = View.VISIBLE

Programmatically added TableRows to a TableLayout don't show

I am new to Android. I tried to add TableRows to a TableLayout but it doesn't work. I have no idea why it doesn't show. I have tried to look from the internet, but seems like my problem isn't the same. I have no exceptions or erros in the logcat. I tried to debug and found out that the views are added but for some reason they don't show. Does anyone have an idea about this? Thanks in advance.
My code:
private void addInfosToTable(){ //this is called in onCreate() function
//these are just dummy infos i want to test the how the table works
Cell cell = new Cell("1234",5000,3000);
cell.setStatus(Cell.Status.COMPLETE);
Cell cell1 = new Cell("1234",5000,3000);
cell1.setStatus(Cell.Status.FAILED);
addCellRowToTable(cell);
addCellRowToTable(cell1);
}
private void addCellRowToTable(Cell cell){
//init cell info
String cellID = cell.getCellID();
double targetSpeed = cell.targetSpeed();
double targetPoint = cell.targetPoint();
Cell.Status status = cell.getStatus();
//create tableRow
TableRow tableRow = new TableRow(this);
tableRow.addView(getTextView(cellID,true));
tableRow.addView(getTextView("n.a"+"/ "+"n.a",false));
tableRow.addView(getTextView(targetSpeed+"/ "+targetPoint,false));
tableRow.addView(getStatusView(status));
tableRow.setPadding(0,R.dimen.table_marginVertical,R.dimen.table_marginVertical,0);
tableRow.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.MATCH_PARENT));
//add tableRow to tableLayout
this.cellTable.addView(tableRow);
}
private TextView getTextView(String text, boolean isFirst){
TextView textView = new TextView(this);
textView.setTextSize(R.dimen.table_textSize);
textView.setText(text);
textView.setTextColor(ContextCompat.getColor(this,R.color.black));
if (isFirst){
textView.setPadding(R.dimen.table_marginVertical,0,0,0);
}
return textView;
}
private ImageView getStatusView(Cell.Status status){
ImageView imageView = new ImageView(this);
switch (status){
case COMPLETE:
imageView.setImageResource(R.drawable.success);
return imageView;
default:
imageView.setImageResource(R.drawable.failed);
return imageView;
}
}
My table has 4 columns, and it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="superapp.networkapp.MainActivity"
android:focusableInTouchMode="true">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="false"
android:layout_alignParentEnd="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/warning_box"
android:padding="10dp"
android:layout_margin="3dp"
android:weightSum="1">
<TextView
android:layout_width="276dp"
android:layout_height="wrap_content"
android:text="#string/warning_text"
android:id="#+id/main_boxText"
android:layout_margin="3dp"
android:textColor="#color/black"
android:textStyle="bold"
android:layout_weight="0.49"
android:textSize="12sp"
android:textIsSelectable="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/main_boxIcon"
android:src="#drawable/warning_icon"
android:layout_weight="0.47" />
</LinearLayout>
<TableLayout
android:stretchColumns = "*"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/cellListTable">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue"
android:paddingTop="#dimen/table_marginVertical"
android:paddingBottom="#dimen/table_marginVertical"
android:id="#+id/cellTableHeading">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/cells"
android:id="#+id/cell"
android:layout_column="0"
android:textColor="#color/white"
android:textColorHighlight="#color/blue"
android:textSize="#dimen/table_textSize"
android:textIsSelectable="true"
android:paddingLeft="#dimen/table_marginVertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/table_current_info"
android:id="#+id/currentInfo"
android:layout_column="1"
android:textColor="#color/white"
android:textColorHighlight="#color/blue"
android:textSize="#dimen/table_textSize"
android:textIsSelectable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/table_target_info"
android:id="#+id/targetInfo"
android:layout_column="2"
android:textColor="#color/white"
android:textColorHighlight="#color/blue"
android:textSize="#dimen/table_textSize"
android:textIsSelectable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/status"
android:id="#+id/status"
android:layout_column="3"
android:textColor="#color/white"
android:textColorHighlight="#color/blue"
android:textSize="#dimen/table_textSize"
android:textIsSelectable="true"
android:textAlignment="textEnd"
android:paddingRight="#dimen/table_marginVertical" />
</TableRow>
</TableLayout>
</LinearLayout>
I have no idea why it doesn't show. I have tried to look from the internet, but seems like my problem isn't the same. I have no exceptions or erros in the logcat. I tried to debug and found out that the views are added but for some reason they don't show. Does anyone have an idea about this? Thanks in advance.
UPDATE
I edited the layout height of the default view to all wrap_content. I also added this line of code: before adding the tableRow to the tableLayout. But it still does not work.
tableRow.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.MATCH_PARENT));
you have to define a layout for each table row and bind the textViews and ImageView to the corresponding elements in the layout.

How should inflating go right way?

I need to have like several listviews on a scrollview which Android doesn't allow me to do so I decided to make it manually to simply inflate some listrows on a vertical LinearLayout, but everything goes not the right way
private void fillData(final ViewGroup parent, final ArrayList<Person> array ){
for (int i=0;i<array.size();i++){
final View view = lf.inflate(R.layout.personal_listrow, parent,true);
parent.setBackgroundColor(getActivity().getResources().getColor(R.color.background_light_darker));
view.setBackgroundColor(getActivity().getResources().getColor(R.color.background_night_lighter));
TextView tvName=(TextView) view.findViewById(R.id.tvName);
TextView tvStatus=(TextView) view.findViewById(R.id.tvStatus);
TextView tvGender=(TextView) view.findViewById(R.id.tvGender);
//fill textviews with info, set the onClickListeners and so on
}
So what I get - the view.setBackgroundColor paints parent as well .
parent is a vertical LinearLayout, view is horizontal LinearLayout - it's strange that I don't paint inflated element only so please explain me why
The next thing - after I add something to array - 1st element changes and all the rest is with unchanged text. However, I walked through the code with debugger - it passes every element and sets text.
The clicklisteners works on the 1st element only..
Would you plz explain
here's vertical , parent layout - nothing special:
<LinearLayout
android:id="#+id/rodll"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
the inflateable listrow is nothing special also :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvStatus"
android:layout_width="0dp"
android:layout_weight=".3"
android:maxLines="1"
android:layout_height="wrap_content"
android:text="tvSt" />
<TextView
android:id="#+id/tvName"
android:layout_weight="1"
android:layout_width="0dp"
android:maxLines="1"
android:layout_height="wrap_content"
android:text="tvName" />
<TextView
android:id="#+id/tvGender"
android:layout_weight=".1"
android:layout_width="0dp"
android:maxLines="1"
android:layout_height="wrap_content"
android:text="tvGender" />
<com.andexert.library.RippleView
android:id="#+id/removeRipple"
xmlns:ripple="http://schemas.android.com/apk/res-auto"
android:layout_marginLeft="30dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginRight="7.5dip"
android:padding="3dp"
ripple:rv_alpha="255"
ripple:rv_zoom="true"
ripple:rv_zoomScale="0.8"
ripple:rv_type="rectangle">
<ImageView
android:id="#+id/remove_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/remove" />
</com.andexert.library.RippleView>
<com.andexert.library.RippleView
android:id="#+id/addRipple"
xmlns:ripple="http://schemas.android.com/apk/res-auto"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginRight="7.5dip"
android:padding="3dp"
ripple:rv_alpha="255"
ripple:rv_zoom="true"
ripple:rv_zoomScale="0.8"
ripple:rv_type="rectangle">
<ImageView
android:id="#+id/add_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/add" />
</com.andexert.library.RippleView>
</LinearLayout>
So. what's the problem and how to solve it?

ImageView dissapearing after setting an ID

I'm programatically adding views into my layout inside a for loop.
The xml file of the layout I'm adding is like this one:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout_consulta_item_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView_consulta_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/LinearLayout_dados_consulta"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/LinearLayout_dados_consulta"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:adjustViewBounds="true"
android:maxWidth="70dp"
android:padding="10dp"
android:scaleType="centerInside"
android:src="#drawable/estrela_off" />
<LinearLayout
android:id="#+id/LinearLayout_dados_consulta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_toLeftOf="#+id/imageView_consulta_action"
android:background="#660000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="#string/origem"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffaaaa"
android:textSize="10sp" />
<TextView
android:id="#+id/textView_origem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YYY"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#eeeeee" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:text="#string/data_ida"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffaaaa"
android:textSize="10sp" />
<TextView
android:id="#+id/textView_data_ida"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2014-05-05"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#eeeeee"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
In my main_activity, I call the constructor:
for (int i=0;i<resultList.length-1;i++){
RelativeLayout viewToLoad = (RelativeLayout)LayoutInflater.from(this).inflate(R.layout.consulta_item, null);
ll.addView(viewToLoad);
ImageView ImgConsulta_action = (ImageView)findViewById(R.id.imageView_consulta_action);
LinearLayout dados_consulta = (LinearLayout)findViewById(R.id.LinearLayout_dados_consulta);
dados_consulta.setOnLongClickListener(...);
ImgConsulta_action.setOnLongClickListener(...);
Well, I keep setting SetText for all the views in the layout and so on.
But, in order to make the setOnClickListener to work for each view, I must set a id to the views inside the for loop:
dados_consulta.setId(4000+i);
ImgConsulta_action.setId(5000+i); //(*lastline)
The weird thing is happening is that:
If I comment this last line, the layout is inserted correctly with the imageview showing a star as it is suposed to do and the listener at "dados_consulta" works fine.
But if I remove the comment at this last line, the star dissapear from the screen.
Can anybody help me to understand what is going on?
I had an layout params referenced to the ID of the layout elements at the original view.
Since I have to change the ID dynamically while I'm adding this layout several times into my activity, I also need to reset the layoutparams to the new Ids.
So, I added this lines:
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)ImgConsulta_action.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_TOP, dados_consulta.getId());
params.addRule(RelativeLayout.ALIGN_BOTTOM, dados_consulta.getId());
ImgConsulta_action.setLayoutParams(params);
RelativeLayout.LayoutParams paramsDadosConsulta = (RelativeLayout.LayoutParams)dados_consulta.getLayoutParams();
paramsDadosConsulta.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
paramsDadosConsulta.addRule(RelativeLayout.LEFT_OF, ImgConsulta_action.getId());
dados_consulta.setLayoutParams(paramsDadosConsulta);
Now it's working perfectly.
Notice that the problem is not about the layout disappearing it was about a layout get in front of the other one. (making this other one invisible)

android layout with visibility GONE

Four views are using same xml. I want to show a linear layout for view 1 only.
I put android:visibility="gone" in xml. And then I am doing the following for view 1-
LinearLayout layone= (LinearLayout) view.findViewById(R.id.layone);
layone.setVisibility(View.VISIBLE);
But that doesn't set the visibility to visible.
Isn't it possible to show the view once its declared GONE in xml ?
I don't want to converse the logic by just doing,
layone.setVisibility(View.GONE);
in each of the three views except view 1.
Ideas or comments?
UPDATE:
My xml -
<TextView
android:id="#+id/layone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous Page"
android:textColor="#000000"
android:textSize="16dp"
android:paddingLeft="10dp"
android:layout_marginTop="10dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:padding="10dp"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:tag="PrevEntries"
android:id="#+id/laytwo"
android:layout_marginTop="10dp"
android:background="#layout/roundedtext"
android:visibility="gone" >
<TextView
android:id="#+id/laythree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Previous Page"
android:textColor="#000000"
android:textSize="18dp"
android:gravity="center"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/layone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous Page"
android:textColor="#000000"
android:textSize="16dp"
android:paddingLeft="10dp"
android:layout_marginTop="10dp"
android:visibility="gone" />
layone is a TextView.
You got your id wrong.
LinearLayout layone= (LinearLayout) view.findViewById(R.id.laytwo);// change id here
layone.setVisibility(View.VISIBLE);
should do the job.
or change like this to show the TextView:
TextView layone= (TextView) view.findViewById(R.id.layone);
layone.setVisibility(View.VISIBLE);
Done by having it like that:
view = inflater.inflate(R.layout.entry_detail, container, false);
TextView tp1= (TextView) view.findViewById(R.id.tp1);
LinearLayout layone= (LinearLayout) view.findViewById(R.id.layone);
tp1.setVisibility(View.VISIBLE);
layone.setVisibility(View.VISIBLE);
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/activity_register_header"
android:minHeight="50dp"
android:orientation="vertical"
android:visibility="gone" />
Try this piece of code..For me this code worked..
Kotlin Style way to do this more simple (example):
isVisible = false
Complete example:
if (some_data_array.details == null){
holder.view.some_data_array.isVisible = false}
put this attribute in your xml view for Gone
android:visibility="gone"
put this attribute in your xml view for Show
android:visibility="visible"
Example
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/futura_medium_bt"
android:text="•Unlock all graphics"
android:textAllCaps="true"
android:visibility="gone"
android:textColor="#color/black"
android:textSize="#dimen/_12ssp" />

Categories

Resources