Forum Xamarin.Android

custom include Android

RodolfoTorrealbaRodolfoTorrealba USMember ✭✭
edited September 2015 in Xamarin.Android

my xml

  <RelativeLayout
    android:id="@+id/InnerRelativeLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">

  <TextView
   android:id="@+id/textopie"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="| SERVICIOS QR DERECHOS RESERVADOS ® 2015 |"
   android:textColor="#000"
   android:textSize="8sp" 
   android:background="#F0F0F0"
   android:gravity="center"/>

  </RelativeLayout>

my xaml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FFFFFF">
        <include
            layout="@drawable/footer" />
        <include
            android:id="@+id/encabezado"
            layout="@drawable/header" />
        </RelativeLayout>
    </RelativeLayout>

my code c#

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        Window.RequestFeature(WindowFeatures.NoTitle);
        SetContentView(Resource.Layout.relog);
        View view = FindViewById(Resource.Id.encabezado); <--- Resource not find
    }

Answers

  • rzee7rzee7 INUniversity ✭✭✭✭✭

    Hi @RodolfoTorrealba

    If you need your TextView then, you can directly find you TextView control using standard code snippet.

    TextView txtView= FIndViewByID<TextView>(Resource.Id.YourTextViewID); 
    

    Cheers!!
    RIYAZ

  • this error

    The type or namespace name 'textopie' could not be found (are you missing a using directive or an assembly reference?)

    code

     textopie txtView = FIndViewByID<TextView>(Resource.Id.textopie);
    
  • LoriLalondeLoriLalonde CAInsider, University, Developer Group Leader ✭✭✭
    edited September 2015

    When declaring the variable for your textview it should be:

    TextView txtView =...

    instead of

    textopie txtView = ...

  • It worked perfectly thank you

Sign In or Register to comment.