开发者

Android Development Tutorials - "New Member In Activity" in HelloFormStuff [closed]

开发者 https://www.devze.com 2023-02-18 05:36 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_运维知识库

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this question

I am working my way through the tutorials at Android Developers, and have come across a question that I am sure truly shows my newbie status. In step 2 of 'Radio Buttons' in the HelloFormStuff section of the HelloViews tutorial, I am directed to "add the following code to create a new member in the HelloFormStuff Activity: " ... What does that mean?

Do i add another class to the package? (new class dialog in eclipse grays out option for private class)

Do I insert somewhere inside the class HelloFormStuff? (error given: "Illegal modifier for parameter radio_listener; only final is permitted"

Thank you for any help you may provide.


The radio_listener is the new member. A member is like a part of the the class.

So pasting the provided code into the class is actually creating the new member.

It will look something like this (not tested, just read it as "pseudocode" please :) )

class HelloFormStuff extends Activity{

    //other stuff 

     private OnClickListener radio_listener = new OnClickListener() {
        public void onClick(View v) {
           // Perform action on clicks
           RadioButton rb = (RadioButton) v;
           Toast.makeText(HelloFormStuff.this, rb.getText(), Toast.LENGTH_SHORT).show();
        }
     };

   //other stuff, like onCreate();

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号