English 中文(简体)
ClickListener
原标题:Issuue while implementing onClickListener
  • 时间:2011-10-26 06:05:08
  •  标签:
  • android
  • view

See this simple code,But i am getting Description
The method onClick(View) of type CheckboxActivity must override a superclass method CheckboxActivity。java on my onClick(View v) method。

public class CheckboxActivity extends Activity implements Button。OnClickListener{
        /** Called when the activity is first created。 */
        Button b1;
        CheckBox c1, c2;
        EditText et1;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super。onCreate(savedInstanceState);
            setContentView(R。layout。main);
            et1 = (EditText) this。findViewById(R。id。text1);
            c1 = (CheckBox) findViewById(R。id。check1);
            c2 = (CheckBox) findViewById(R。id。check2);
            b1 = (Button) findViewById(R。id。button1);
            b1。setOnClickListener(this);
        }

        @Override 
           public void onClick(View v){
            et1。setText("");
            if (c1。isChecked())
            et1。setText("Android ");
            if (c2。isChecked())
            et1。setText(et1。getText()+"iPhone ");
        }
    }

Anyone please help

最佳回答

Try:

public class CheckboxActivity extends Activity implements OnClickListener
问题回答

You delete your onClick() first. Then change ur first line as

public class CheckboxActivity extends Activity implements OnClickListener

进口

android.view.View.OnClickListener;

之后,在您的网页上填写了right Point-> Source -> Override/Implemented Methods

将在方言箱中自动选定浮标。 蒸.和尿体的类型要求将货物输入这种方法。

我没有活动来源,没有工作环境来撰写法典并管理ava,因此我只是猜测。

  1. Activity has onClick method already - make anonymous OnClickListener instance and pass it to the button (or remove inheritance from Button.OnClickListener and don t forget to call super when view is not your button). Could be also that contract has different access level in activity.
  2. Level of language is 1.5 and you can t use annotation @override for interfaces.




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签