1. <legend id='dgLhS'><style id='dgLhS'><dir id='dgLhS'><q id='dgLhS'></q></dir></style></legend>

    2. <small id='dgLhS'></small><noframes id='dgLhS'>

      <tfoot id='dgLhS'></tfoot>

      1. <i id='dgLhS'><tr id='dgLhS'><dt id='dgLhS'><q id='dgLhS'><span id='dgLhS'><b id='dgLhS'><form id='dgLhS'><ins id='dgLhS'></ins><ul id='dgLhS'></ul><sub id='dgLhS'></sub></form><legend id='dgLhS'></legend><bdo id='dgLhS'><pre id='dgLhS'><center id='dgLhS'></center></pre></bdo></b><th id='dgLhS'></th></span></q></dt></tr></i><div id='dgLhS'><tfoot id='dgLhS'></tfoot><dl id='dgLhS'><fieldset id='dgLhS'></fieldset></dl></div>
          <bdo id='dgLhS'></bdo><ul id='dgLhS'></ul>

        Android 开发:按钮 onClickListeners 帮助

        Android Development: Button onClickListeners Help(Android 开发:按钮 onClickListeners 帮助)
          <i id='VRybj'><tr id='VRybj'><dt id='VRybj'><q id='VRybj'><span id='VRybj'><b id='VRybj'><form id='VRybj'><ins id='VRybj'></ins><ul id='VRybj'></ul><sub id='VRybj'></sub></form><legend id='VRybj'></legend><bdo id='VRybj'><pre id='VRybj'><center id='VRybj'></center></pre></bdo></b><th id='VRybj'></th></span></q></dt></tr></i><div id='VRybj'><tfoot id='VRybj'></tfoot><dl id='VRybj'><fieldset id='VRybj'></fieldset></dl></div>
              <tbody id='VRybj'></tbody>
            <legend id='VRybj'><style id='VRybj'><dir id='VRybj'><q id='VRybj'></q></dir></style></legend>
              <bdo id='VRybj'></bdo><ul id='VRybj'></ul>
              <tfoot id='VRybj'></tfoot>

              • <small id='VRybj'></small><noframes id='VRybj'>

                1. 本文介绍了Android 开发:按钮 onClickListeners 帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Basically, so far I've just got an add and minus button which will change the value of a TextView.

                  I followed the second example under "Event Listeners" on http://developer.android.com/guide/topics/ui/ui-events.html

                  The problem is I get 4 errors when I go to compile, I don't see what I'm doing wrong?

                  Please can someone point out if there is anything wrong, or show me a simpler way please.

                  Thank you for your time.

                  Here's the errors:

                  /home/alex/NetBeansProjects/GolfScoreCard/src/com/alex/golfscorecard/MainActivity.java:19: com.alex.golfscorecard.MainActivity is not abstract and does not override abstract method onClick(android.content.DialogInterface,int) in android.content.DialogInterface.OnClickListener
                  public class MainActivity extends Activity implements OnClickListener{
                  /home/alex/NetBeansProjects/GolfScoreCard/src/com/alex/golfscorecard/MainActivity.java:49: setOnClickListener(android.view.View.OnClickListener) in android.view.View cannot be applied to (com.alex.golfscorecard.MainActivity)
                          buttonMinus.setOnClickListener(this);
                  /home/alex/NetBeansProjects/GolfScoreCard/src/com/alex/golfscorecard/MainActivity.java:50: setOnClickListener(android.view.View.OnClickListener) in android.view.View cannot be applied to (com.alex.golfscorecard.MainActivity)
                          buttonPlus.setOnClickListener(this);
                  /home/alex/NetBeansProjects/GolfScoreCard/src/com/alex/golfscorecard/MainActivity.java:51: setOnClickListener(android.view.View.OnClickListener) in android.view.View cannot be applied to (com.alex.golfscorecard.MainActivity)
                          buttonOK.setOnClickListener(this);
                  

                  Here is my code:

                  package com.alex.golfscorecard;
                  
                  import android.app.Activity;
                  import android.content.DialogInterface.OnClickListener;
                  import android.os.Bundle;
                  import android.view.View;
                  import android.widget.Button;
                  import android.widget.TextView;
                  
                  /**
                   *
                   * @author alex
                   */
                  public class MainActivity extends Activity implements OnClickListener{
                    Button buttonMinus, buttonPlus, buttonOK;
                    TextView golfScore;
                  
                      // Implement the OnClickListener callback
                      // Incomplete!
                      public void onClick(View v) {
                        switch(v.getId()){
                            case R.id.buttonMinus:
                            score--;
                            break;
                            case R.id.buttonPlus:
                            score++;
                            break;
                        }
                      }
                  
                      /** Called when the activity is first created. */
                      @Override
                      public void onCreate(Bundle icicle) {
                          super.onCreate(icicle);
                          setContentView(R.layout.main);
                  
                          //Set the UI elements and find their view in main.xml
                          buttonMinus = (Button) findViewById(R.id.buttonMinus);
                          buttonPlus = (Button) findViewById(R.id.buttonPlus);
                          buttonOK = (Button) findViewById(R.id.buttonOK);
                          golfScore = (TextView) findViewById(R.id.golfScore);
                  
                          //Set the UI elements' on click listeners
                          buttonMinus.setOnClickListener(this);
                          buttonPlus.setOnClickListener(this);
                          buttonOK.setOnClickListener(this);
                  
                      }
                  
                  }
                  

                  解决方案

                  You have imported wrong OnClickListener. Change

                  import android.content.DialogInterface.OnClickListener;
                  

                  to

                  import android.view.View.OnClickListener;
                  

                  这篇关于Android 开发:按钮 onClickListeners 帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)
                        <tbody id='iUb3y'></tbody>

                    • <legend id='iUb3y'><style id='iUb3y'><dir id='iUb3y'><q id='iUb3y'></q></dir></style></legend>

                      <tfoot id='iUb3y'></tfoot>

                          • <bdo id='iUb3y'></bdo><ul id='iUb3y'></ul>

                          • <small id='iUb3y'></small><noframes id='iUb3y'>

                            <i id='iUb3y'><tr id='iUb3y'><dt id='iUb3y'><q id='iUb3y'><span id='iUb3y'><b id='iUb3y'><form id='iUb3y'><ins id='iUb3y'></ins><ul id='iUb3y'></ul><sub id='iUb3y'></sub></form><legend id='iUb3y'></legend><bdo id='iUb3y'><pre id='iUb3y'><center id='iUb3y'></center></pre></bdo></b><th id='iUb3y'></th></span></q></dt></tr></i><div id='iUb3y'><tfoot id='iUb3y'></tfoot><dl id='iUb3y'><fieldset id='iUb3y'></fieldset></dl></div>