1. Check out our companion app, Forums for Android! Download from Google Play

Implement onclick listener for but on Custom Dialog

Discussion in 'Application Development' started by cowboy, Mar 28, 2010.

  1. cowboy

    cowboy New Member
    Thread Starter
    5

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

    PHP:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.               android:id="@+id/layout_root"
    4.               android:orientation="horizontal"
    5.               android:layout_width="fill_parent"
    6.               android:layout_height="fill_parent"
    7.               android:padding="10dp"
    8.               >
    9.    
    10.    
    11.  
    12.  
    13.  
    14. <EditText android:id="@+id/EditText01"
    15. android:layout_width="wrap_content"
    16. android:layout_height="wrap_content"></EditText>
    17.  
    18. <Button android:layout_width="wrap_content"
    19. android:layout_height="wrap_content"
    20. android:text="&#1055;&#1088;&#1086;&#1074;&#1077;&#1089;&#1090;&#1080;"
    21. android:id="@+id/Enter"></Button>
    22. </LinearLayout>
    AFter that i tried to add on click listener on this form..How i can do this? WHen i wrote
    Code (Text):
    1.  EnterButoon=(Button) findViewById(R.id.Enter);
    2. EnterButoon.setOnClickListener(this);
    3.  
    within Oncreate the application had crashed in emulator with error UNNABLE TO START ACTIVITY.
    Code (Text):
    1.  @Override
    2.     protected Dialog onCreateDialog(int id) {
    3.     Context mContext = getApplicationContext();
    4.     Dialog dialog = new Dialog(this);
    5.  
    6.     dialog.setContentView(R.layout.custom_dialog);
    7.     dialog.setTitle("&#1042;&#1074;&#1077;&#1076;&#1080;&#1090;&#1077; &#1082;&#1072;&#1090;&#1077;&#1075;&#1086;&#1088;&#1080;&#1102;");
    8.    
    9.     return dialog;
    10.     }
    11.  
     

    Advertisement

Share This Page

Loading...