Some ways you can do this:

(1) Have the activity set the on click listener and implement it to call
finish() on itself.
(2) Have an API on the view to set the Activity it is running in, so it can
call finish() on that.
(3) Have a different callback of your View subclass that reports when finish
should be called, which the activity can set with an appropriate
implementation.

On Mon, Jun 6, 2011 at 3:18 PM, kaushik p <kaushiks...@gmail.com> wrote:

> How can the activity be accessed in the onclick() of the button , ??
> finish() inside the onclick is not working  .
>
> close.setOnClickListener(new View.OnClickListener()
> {
>  public void onClick(View v)
> {
> finish();
>           Intent Newbtn1 = new Intent(v.getContext(),help.class);
> startActivityForResult(Newbtn1,0);
>          }
>                 });
>
>
> when i do this, the intent is working rather than the finish (); each time
> . Please help me to resolve this .
>
> On Mon, Jun 6, 2011 at 4:17 AM, Dianne Hackborn <hack...@android.com>wrote:
>
>> When you get the back button, call finish() on your activity.  That's all
>> the default implementation does.
>>
>> On Sun, Jun 5, 2011 at 12:09 PM, kaushik p <kaushiks...@gmail.com> wrote:
>>
>>> Hi all
>>>
>>> can anyone please help me implementing the back button in my app
>>> exclusively?? I am building an app to help illiterate ppl , so they do not
>>> know how to use the android back button ,i need to exclusively put it on the
>>> screen .
>>>
>>> However i want to use  my back button exactly ia the  way, natural back
>>> button works. For example , it should be like i click my back button on the
>>> screen then it should trigger the natural back button click .
>>>
>>>
>>> --
>>> Thanks&Regards
>>> Kaushik Pendurthi
>>>
>>> http://kaushikpendurthi.blogspot.com/
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> android-developers+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>>
>>
>> --
>> Dianne Hackborn
>> Android framework engineer
>> hack...@android.com
>>
>> Note: please don't send private questions to me, as I don't have time to
>> provide private support, and so won't reply to such e-mails.  All such
>> questions should be posted on public forums, where I and others can see and
>> answer them.
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>
>
> --
> Thanks&Regards
> Kaushik Pendurthi
>
> http://kaushikpendurthi.blogspot.com/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to