android – 无法找到onClick方法

android – 无法找到onClick方法,第1张

概述所以,我收到了这个错误 11-15 16:55:40.617: E/AndroidRuntime(316): java.lang.IllegalStateException: Could not find a method ingresarBtnClick(View) in the activity class android.view.ContextThemeWrapper for onClic 所以,我收到了这个错误
11-15 16:55:40.617: E/AndroIDRuntime(316): java.lang.IllegalStateException: Could not find a method ingresarBtnClick(VIEw) in the activity class androID.vIEw.ContextthemeWrapper for onClick handler on vIEw class androID.Widget.button with ID 'ingresarbutton'

这是我的布局xml

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent" androID:orIEntation="vertical" androID:weightSum="1" androID:ID="@+ID/Login">    <TextVIEw androID:layout_wIDth="wrap_content" androID:ID="@+ID/textVIEw1" androID:textAppearance="?androID:attr/textAppearanceLarge" androID:text="Número de Lecturista" androID:layout_height="wrap_content"></TextVIEw>    <EditText androID:inputType="number" androID:layout_height="wrap_content" androID:layout_wIDth="match_parent" androID:ID="@+ID/numLecEditText" androID:maxLength="4">        <requestFocus></requestFocus>           </EditText>    <TextVIEw androID:layout_wIDth="wrap_content" androID:ID="@+ID/textVIEw2" androID:textAppearance="?androID:attr/textAppearanceLarge" androID:layout_height="wrap_content" androID:text="PIN"></TextVIEw>    <EditText androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:inputType="number" androID:password="true" androID:ID="@+ID/pinEditText" androID:maxLength="4"></EditText>    <tableRow androID:ID="@+ID/tableRow1" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content">        <button androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Ingresar" androID:ID="@+ID/ingresarbutton" androID:onClick="ingresarBtnClick"></button>        <button androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Salir" androID:ID="@+ID/salirbutton" androID:onClick="salirBtnClick"></button>        <button androID:ID="@+ID/opcionesbutton" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Opciones" androID:onClick="opcionesBtnClick" ></button>    </tableRow></linearLayout>

这是我的代码

import androID.app.Dialog;import androID.vIEw.VIEw;import androID.Widget.EditText;public class FormaLogin extends Dialog{    SisLec sisLec;    public FormaLogin(SisLec _sisLec)    {               super(_sisLec);             sisLec = _sisLec;               setTitle("IDentificación de Lecturista");    }    public voID mostrar()    {        setContentVIEw(R.layout.login);        show();    }    public voID ingresarBtnClick(VIEw vIEw)    {        EditText numLecTxt = (EditText) sisLec.findVIEwByID(R.ID.numLecEditText);        EditText pinTxt = (EditText) sisLec.findVIEwByID(R.ID.pinEditText);        if(numLecTxt.getText().length() > 0)        {            if(pinTxt.getText().length() > 0)            {                if(numLecTxt.getText().equals("1337"))                {                    if(pinTxt.getText().equals("8383"))                    {                        //sisLec.frmMantenimIEnto.mostrar();                    }                }                else                {                    HiloIDentificacion hiloIDen = new HiloIDentificacion();                    hiloIDen.IDentificacion(numLecTxt.getText().toString(),pinTxt.getText().toString());                }            }            else                sisLec.mensaje("Debe de ingresar su pin");        }        else            sisLec.mensaje("Debe de ingresar su número de Lecturista");    }    public voID salirBtnClick(VIEw vIEw)    {        sisLec.salir();    }    public voID opcionesBtnClick(VIEw vIEw)    {        // Todo: Agregar método que muestre la forma de Opciones    }    private class HiloIDentificacion extends Thread    {        private String usuario,pass;        public synchronized voID run()        {            try            {                sisLec.IDentificacion(usuario,pass);            }            catch(Exception e)            {                // Todo: Agregar registro de error            }                           }        public synchronized voID IDentificacion(String _usuario,String _pass)        {            usuario = _usuario;            pass = _pass;            run();        }    }}

分配给按钮“ingresarbutton”,“ingresarBtnClick(视图视图)”的方法就在那里,因为Androir文档建议http://developer.android.com/guide/topics/ui/ui-events.html但是我收到了错误.

我在Dialog上显示这个布局有什么可做的吗?

SisLec是我的Activity类

解决方法 androID:onClick在xml中将事件路由到活动中的方法.但是你的方法不在Activity中,而是在你的Dialog类中.您需要让您的活动转发对Dialog实例的调用,或让对话框代码将自身注册为onClick侦听器,而不是尝试在布局中设置它. 总结

以上是内存溢出为你收集整理的android – 无法找到onClick方法全部内容,希望文章能够帮你解决android – 无法找到onClick方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1133189.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存