• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Implement onclick listener for but on Custom Dialog

cowboy

Lurker
Mar 22, 2010
4
0
I ve created Custom Dialog with Button on them :

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:padding="10dp"
              >
    
    



<EditText android:id="@+id/EditText01" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"></EditText>

<Button android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="&#1055;&#1088;&#1086;&#1074;&#1077;&#1089;&#1090;&#1080;" 
android:id="@+id/Enter"></Button>
</LinearLayout>

AFter that i tried to add on click listener on this form..How i can do this? WHen i wrote
Code:
 EnterButoon=(Button) findViewById(R.id.Enter);
EnterButoon.setOnClickListener(this);
within Oncreate the application had crashed in emulator with error UNNABLE TO START ACTIVITY.
Code:
 @Override
    protected Dialog onCreateDialog(int id) {
    Context mContext = getApplicationContext();
    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.custom_dialog);
    dialog.setTitle("&#1042;&#1074;&#1077;&#1076;&#1080;&#1090;&#1077; &#1082;&#1072;&#1090;&#1077;&#1075;&#1086;&#1088;&#1080;&#1102;");
    
    return dialog;
    }
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones