0
Hello, good afternoon. I’m new to Android programming and am unable to save the ID of a relativeLayout to be compared.
Example:
 <RelativeLayout
        android:id="@+id/idAmc"
        android:layout_width="match_parent"
        android:layout_height="65dp"
        android:layout_marginBottom="15dp"
        android:background="@drawable/shadow_grey"
        android:clickable="true"
        android:onClick="selecionaMenuTec">
        <ImageView
            android:id="@+id/ic_amc"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="15dp"
            app:srcCompat="@drawable/ic_amc" />
        <TextView
            android:id="@+id/amc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/amc"
            android:textAlignment="center" />
        <TextView
            android:id="@+id/empresaAmc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginStart="12dp"
            android:layout_toEndOf="@+id/ic_amc"
            android:text="ABC Empresa"
            android:textAppearance="@style/TextAppearance.AppCompat.Body2"
            android:textSize="15sp" />
        <TextView
            android:id="@+id/mediaAmc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/empresaAmc"
            android:layout_marginLeft="180dp"
            android:text="@string/media" />
        <TextView
            android:id="@+id/mediaValorAmc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="5dp"
            android:text="0%"
            android:textSize="25sp"
            android:layout_alignParentBottom="true"
            android:layout_toEndOf="@+id/mediaAmc" />
    </RelativeLayout>
How do I take the ID of this relativeLayout and save to a variable for future comparison?
I have tried using findViewById() but certainly not.
I want to do something like: `
public class menuTec extends AppCompatActivity{
public void selecionaMenuTec(RelativeLayout view)
{
    RelativeLayout layoutMenuTec = view;
    if( view == R.id.idAmc){
    }
}
}
You want to receive this value: idAmc?
– itscorey
You’re in a Fragment?
– Leonardo Dias
I want to get this idAmc. The idea is to check this idAMc in an if. And call a Fragment. @Luc
– Lucas Charles
I want to receive this idAmc. The idea is to check this idAMc in an if. And call a Fragment @Leonardodias
– Lucas Charles