Скрыть элемент при создании inflater

Я создаю несколько блоков

Integer i = 0;
Boolean hide = false;
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
final LinearLayout mparent = (LinearLayout) findViewById(R.id.BaseContainer);
while (cursor.moveToNext()) {
    nameIndex = cursor.getColumnIndex("name");

    final View myview = layoutInflater.inflate(R.layout.inflater, null, false);

    TextView tv_inflater_name = (TextView) myview.findViewById(R.id.inflater_name);
    tv_inflater_name.setText(cursor.getString(nameIndex));
    if(i == 2) {
        hide = true;
    } else {
        hide = false;
    }
    i++;
    if (hide) {
        tv_s2 = myview.findViewById(R.id.inflater_size);
        tv_s2.setVisibility(View.GONE);
    }
    mparent.addView(myview);
}

И в при создании хочу в некоторых скрыть один элемент. Использую

tv_s2 = findViewById(R.id.inflater_size);
tv_s2.setVisibility(View.GONE);

Элемент скрывается, но только у первого созданного блока, а не у того, которого мне нужно

activity_my.xml

<LinearLayout
    android:id="@+id/BaseContainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/main_margin_lr"
    android:layout_marginRight="@dimen/main_margin_lr"
    android:orientation="vertical">
</LinearLayout>

inflater.xml

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="2dp"
    android:orientation="vertical"
    android:paddingBottom="15dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="20dp">
                <TextView
                    android:id="@+id/inflater_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:textColor="@android:color/black"/>
                <TextView
                    android:id="@+id/inflater_size"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:gravity="end"
                    android:textColor="@android:color/black"/>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</FrameLayout>

Ответы (0 шт):