hi,
You have to do setContent View Before you do Button button =
(Button)findViewById(R.id.okButt);




On Tue, Apr 8, 2008 at 5:45 PM, basant <[EMAIL PROTECTED]> wrote:

>
> Hi Friends,
>
>  Can any body, please tell me how to listen to a button click.I have
> written code for that but it's throwing null pointer exception.
>
> I am pasting my code,
> **************************************************
> package pkg.pkg1;
>
> import android.app.Activity;
>
> import android.os.Bundle;
> import android.text.Layout.Alignment;
> import android.view.View;
> import android.view.View.OnClickListener;
>
> import android.widget.Button;
> import android.widget.EditText;
> import android.widget.TextView;
>
> public class Activity1 extends Activity {
>    /** Called when the activity is first created. */
>    @Override
>    protected void onCreate(Bundle savedValues) {
>        super.onCreate(savedValues);
>
>
>         Button button = (Button)findViewById(R.id.okButt);
>         //OnClickListener mCorkyListener = new OnClickListener();
>         button.setOnClickListener(mCorkyListener);
>         setContentView(R.layout.first);
>     }
>    private OnClickListener mCorkyListener = new OnClickListener()
>    {
>        public void onClick(View v)
>        {
>            // To send a result, simply call setResult() before your
>            // activity is finished.
>                setContentView(R.layout.second);
>        }
>    };
>
>  }
> *************************************************
>
>
>
>
> Please help me, it's urgent.
>
> Thanks & Regards,
> Basant.
> >
>


-- 
Deepak Kumar Singh

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to