c# - Error CS0120 with FindViewById in Xamarin/Android -
i have error findviewbyid under xamarin/android: error cs0120 object reference required property , method, or non-static field ' . here axml file:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layoutdeadreckoning" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/startx" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff66ff66" android:padding="20px" android:text="startx" /> </linearlayout>
and here code
public class deadreckoningactivity : activity {//declaration protected override void oncreate(bundle savedinstancestate) { base.oncreate(savedinstancestate); // create application here setcontentview(resource.layout.activity_dead_reckoning); int method = intent.getintextra(key_reckoning_method, method_dead_reckoning); mdeadreckoning = new deadreckoning(this); //class intent = new intent(this, typeof( broadcastservice) ); // public class broadcastservice : service } [broadcastreceiver(enabled = true)] [intentfilter(new[] { android.content.intent.actionbootcompleted })] private class broadcastreceiver : broadcastreceiver { public override void onreceive(context context, intent intent) { updateui(intent); } private void updateui(intent intent) { float mstartx = mdeadreckoning.getmstartx(); textview startx =findviewbyid<textview>(resource.id.startx); startx.settext(convert.tochar(mstartx)); } } }
can see going wrong?
Comments
Post a Comment