0

One stupid question is running on my mind.

In Android, every time an OnClickListener or an event is generated i.e. an autostub is generated after the event,

we have to manually keep the semicolon after the ).

What is the reason behind that? Why is Android SDK not directly keeping the semicolon?

 texthome.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

    }
}***);***

Just asked so as to clear the concepts. Thanks in advance :)

Shachi
  • 1,858
  • 3
  • 23
  • 41
  • 1
    Nothing to do with the SDK. What IDE do you use? – Simon Feb 12 '13 at 07:38
  • Android ADT in eclipse plugin. But I really don't think its related with the IDE. – Shachi Feb 12 '13 at 07:40
  • 2
    It's the IDE that generates the template code. I don't use Eclipse but in my IDE, the templates are editable. I can change the auto-generate to whatever I want. I'm sure Eclipse will have the same feature. – Simon Feb 12 '13 at 07:43
  • ofcourse it can be ddited. Infact,as per the code,If I dont put a ; after ) it results into error. But, I got your reasoning about the IDE that generates template code. Thanks. :) – Shachi Feb 12 '13 at 07:45
  • define "manually keep the semicolon" ? – njzk2 Feb 12 '13 at 07:47
  • see the * part in my code posted here. On generation of autostub, there is no ; after roundbracket,by default which results into error. It works perfect after adding colon. – Shachi Feb 12 '13 at 07:54
  • 1
    Template is only for OnClickListener, semicolon is for your own setOnClickListener. IDE doesn't know which context you are using it in, and doesn't assuming unnecessarily. – auselen Feb 12 '13 at 08:00
  • you mean IDE is not aware which event listener is being taken?? @auselen – Shachi Feb 12 '13 at 08:01
  • what does that to do with semicolon? semicolon is for terminating texthome.setOnClickListener line. – auselen Feb 12 '13 at 08:10
  • but why does IDE directly not keep ; while generating the autostub? Yes,termination is necessary,so why Ide not only put it instead of making us put it? – Shachi Feb 12 '13 at 08:15

1 Answers1

0

Well,I got a faint idea about it. Semicolon will be there in some methods like methods generated for Intent as there wont be any possibility of a succeeding code at the end of that method.

Whereas,

In other auto generating stubs, the comma wont be there where there is a possibility of some code like show() succeeding it.

I am not sure about it.Can my consideration be right??

Shachi
  • 1,858
  • 3
  • 23
  • 41