xamarin.android - button onclick event dont work in xamarin -
i have problem code. have created button "sign up", want when click on button dialog called "dialog_signup appear.
the problem doesnt appear. , error far
**2>a numeric comparison attempted on "$(_devicesdkversion)" evaluates "" instead of number, in condition "$(_devicesdkversion) >= 21". 2>build failed. 2> ========== build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== ========== deploy: 0 succeeded, 1 failed, 0 skipped ==========**
here code
mainactivity.cs
using system; using android.app; using android.content; using android.runtime; using android.views; using android.widget; using android.os; using android.content.res; namespace gamelandplus { [activity(label = "gamelandplus", mainlauncher = true, icon = "@drawable/icon")] public class mainactivity : activity { private button mbtnsignup; protected override void oncreate(bundle bundle) { base.oncreate(bundle); setcontentview(resource.layout.main); mbtnsignup = findviewbyid<button>(resource.id.btnsignup); mbtnsignup.click += (object sender, eventargs args) => { fragmenttransaction transaction = fragmentmanager.begintransaction(); dialog_signup signupdialog = new dialog_signup(); signupdialog.show(transaction, "dialog fragment"); }; } } }
-->
main.axml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/background_light" android:weightsum="100" android:minwidth="25px" android:minheight="25px"> <imageview android:src="@drawable/images" android:layout_width="match_parent" android:layout_weight="20" android:layout_height="0dp" android:id="@+id/imageview1" /> <textview android:text="create account" android:textappearance="?android:attr/textappearancemedium" android:layout_width="match_parent" android:layout_weight="20" android:layout_height="0dp" android:textcolor="#000000" android:id="@+id/createaccount" android:textsize="35sp" android:gravity="center" android:textstyle="bold" /> <button android:layout_width="match_parent" android:layout_weight="10" android:layout_height="0dp" android:gravity="center" android:id="@+id/signin" android:textcolor="#ffffff" android:background="@drawable/butto1" android:layout_marginleft="40dp" android:layout_marginright="40dp" android:text="sign in" android:shadowcolor="#a8a8a8" android:shadowdx="0" android:shadowdy="0" android:shadowradius="5" /> <textview android:text="or" android:textappearance="?android:attr/textappearancemedium" android:layout_width="match_parent" android:layout_weight="15" android:layout_height="0dp" android:id="@+id/or" android:textcolor="#000000" android:textsize="35sp" android:gravity="center" android:textstyle="bold" /> <button android:text="sign up" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="10" android:id="@+id/btnsignup" android:textcolor="#ffffff" android:background="@drawable/butto1" android:layout_marginleft="40dp" android:layout_marginright="40dp" android:shadowcolor="#00ffffff" android:shadowradius="5" android:drawableright="@drawable/goodmess" /> <relativelayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="35" android:minheight="15px" android:minwidth="15px"> <progressbar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/progressbar1" android:background="@drawable/progressbar" android:indeterminate="true" android:layout_centerinparent="true" /> </relativelayout> </linearlayout>
-->
the dialog page want pop when click on button
dialogsignup.axml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#f1f3f4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minheight="300dp" android:minwidth="300dp"> <edittext android:inputtype="textpersonname" android:layout_width="match_parent" android:layout_height="40dp" android:id="@+id/firstname" android:background="@drawable/editstyle" android:layout_marginbottom="10dp" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:layout_margintop="25dp" android:hint="username" android:paddingleft="10dp" android:paddingright="10dp" android:textcolor="#000" /> <edittext android:layout_below="@+id/firstname" android:inputtype="textemailaddress" android:layout_width="match_parent" android:layout_height="40dp" android:id="@+id/textemail" android:background="@drawable/editstyle" android:layout_marginbottom="10dp" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:hint="email/phone number" android:paddingleft="10dp" android:paddingright="10dp" android:textcolor="#000" /> <edittext android:layout_below="@+id/textemail" android:inputtype="textpassword" android:layout_width="match_parent" android:layout_height="40dp" android:id="@+id/password" android:background="@drawable/editstyle" android:layout_marginbottom="10dp" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:hint="password" android:paddingleft="10dp" android:paddingright="10dp" android:textcolor="#000" /> <button android:layout_below="@+id/password" android:text="sign up" android:layout_width="match_parent" android:layout_height="50dp" android:id="@+id/btndialogemail" android:textcolor="#ffffff" android:background="@drawable/butto1" android:layout_marginleft="40dp" android:layout_marginright="40dp" android:shadowcolor="#00ffffff" android:shadowradius="5" android:drawableright="@drawable/goodmess" /> </relativelayout>
-->
and dialog_signup.cs
using android.views; using android.widget; namespace gamelandplus { class dialog_signup:dialogfragment { public override view oncreateview(layoutinflater inflater, viewgroup container, bundle saveinstancestate) { base.oncreateview(inflater, container, saveinstancestate); var view = inflater.inflate(resource.layout.dialogsignup, container, false); return view; } public override void onactivitycreated(bundle savedinstancestate) { dialog.window.requestfeature(windowfeatures.notitle);//set title base.onactivitycreated(savedinstancestate); dialog.window.attributes.windowanimations = resource.style.dialog_animation; } } }
--> not include slideup/slideright/butto1 because drawable file. please can u check on it. change emulator far. dont know problem. suggestion?
Comments
Post a Comment