That's absolutely right, but in my case I was looking for performing
onClick event because I didn't had access to save() method, that was
initially the only solution .
Thank you all for you advices I really appreciate it.

Best regards.

On 25 fév, 18:05, Robert Green <[email protected]> wrote:
> Let me just say that as someone with a lot of UI development
> experience (in Android, SWT and Swing anyways), if you're looking to
> programmatically push controls, your design is most likely wrong.
>
> I have developed maybe 50-100 screens of GUIs and have never needed
> that functionality.  Consider this - you have a button that has some
> anonymous inner class action handler.  Normal, right?
>
> So here's my save button code:
>
>                 Button saveButton = (Button) findViewById(R.id.save_button);
>                 saveButton.setOnClickListener(new OnClickListener() {
>                         public void onClick(View v) {
>                                 dataMgr.setUserName(userNumber,
> nameEdit.getText().toString().trim());
>                                 finish();
>                         }
>                 });
>
> Let's say we wanted the app to programmatically "press" that button.
> How do I do it?  Answer: That right there is a fundamentally wrong way
> to look at it.  We don't need to "press" it, we need to refactor it.
>
> Consider adding this private method:
> private void save() {
>                                 dataMgr.setUserName(userNumber,
> nameEdit.getText().toString().trim());
>                                 finish();
>
> }
>
> Now change the button to:
>
>                 Button saveButton = (Button) findViewById(R.id.save_button);
>                 saveButton.setOnClickListener(new OnClickListener() {
>                         public void onClick(View v) {
>                                 save();
>                         }
>                 });
>
> And when we want to "press" the button, instead, we just call save().
>
> That can be applied to every situation in some form or another.  You
> should never have to fake input from the user and if you have critical
> code that can only be called via a user input, your design is flawed
> but you can usually fix it by moving that code out into private
> methods.
>
> On Feb 25, 6:39 am, skink <[email protected]> wrote:
>
>
>
> > On Feb 25, 1:23 pm, Houcem Berrayana <[email protected]>
> > wrote:
>
> > > Aaaaaah! so that's may be the reason. I am actually using a custom
> > > build but we just modified some low level libraries. Any way thank you
> > > very much for your help.
>
> > > On 25 fév, 12:23, skink <[email protected]> wrote:
>
> > > > On Feb 25, 11:41 am, Houcem Berrayana <[email protected]>
> > > > wrote:
>
> > > > > I got always the same problem :(
> > > > > I'll try to join my code. It's rises the exception when I click on the
> > > > > button.
>
> > > > it runs just fine.
>
> > > > you probably have custom android build based on 1.5 and apparently
> > > > something is broken, am i right?
>
> > > > pskink
>
> > see what's wrong in PhoneWindow.jawa line 553
>
> > pskink

-- 
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to