java.lang.IllegalStateException: Could not find a method onStartSingleInstanceActivityClickLisenter(
来源:互联网 发布:淘宝四川正品小店卖假 编辑:程序博客网 时间:2024/05/21 18:39
错误类型:java.lang.IllegalStateException: Could not find a method onStartSingleInstanceActivityClickLisenter(View) in the activity class com.xhsc.launchmodel.StandardActivity for onClick handler on view class android.widget.Button with id 'launmodel_satandard_btn'
1、这是采用xml布局代码中的onclick点击事件方法 android:onClick="onStartSingleInstanceActivityClickLisenter"
2、对应在我的 public class StandardActivity extends Activity 类中的
public void onStartSingleInstanceActivityClickLisenter(){
startActivity(new Intent(this, SingleInstanceActivtiy.class));
}
3、找出原因是因为少了参数(View v)public void onStartSingleInstanceActivityClickLisenter(View v){
startActivity(new Intent(this, SingleInstanceActivtiy.class));
}
所以在XML重定义按钮点击方法时,一定要在对应的类中的方法加上参数(View v)
以下是xml布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/launmodel_standard_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StandardActivity" />
<Button
android:id="@+id/launmodel_satandard_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onStartSingleInstanceActivityClickLisenter"
android:text="确定" />
</LinearLayout>
这是对应Java类代码
package com.xhsc.launchmodel;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.xhsc.layout.relativelayout.R;
/**
*
* @author scxh
*standard模式是默认的启动模式,不用为<activity>配置android:launchMode属性即可,当然也可以指定值为standard。
*/
public class StandardActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.launchmodel_standard);
((TextView)findViewById(R.id.launmodel_standard_txt)).setText("StandardActivity current task id: "+">>>>>>>>"+this.getTaskId());
}
/*这里已遗漏参数/
public void onStartSingleInstanceActivityClickLisenter(View v){
startActivity(new Intent(this, SingleInstanceActivtiy.class));
}
}
- java.lang.IllegalStateException: Could not find a method onStartSingleInstanceActivityClickLisenter(
- java.lang.IllegalStateException: Could not find a method capture(View) in the activity class
- android 报错 java.lang.IllegalStateException: Could not find a method next(View)
- java.lang.IllegalStateException: Could not find a method false(View) in the activity class com.xuan
- java.lang.IllegalStateException: Could not find method onClickcrea(View) in a parent or ancestor Con
- java.lang.IllegalStateException: Could not find a method add(View) in the activity class haha.com.e
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- [Android]IllegalStateException: Could not find method onBind(View)
- xfire+spring2.0整合出现[java.lang.IllegalStateException: Could not find valid implementation for: 2.0]
- xfire java.lang.IllegalStateException: Could not initialize Service
- xfire java.lang.IllegalStateException: Could not initialize Service
- java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @BootstrapWi
- java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @BootstrapWi
- xfire报错java.lang.IllegalStateException: Could not initialize Service.
- java.lang.IllegalStateException: Could not auto-size column.
- java.lang.IllegalStateException: @Resource annotation requires a single-arg method
- 网络扫描技术揭秘
- 黑马程序员——Java基础---多线程
- ios8 statusBar hidden and show
- 数据库分库分表-水平分表笔记
- 端上保证可靠性还是链路保证
- java.lang.IllegalStateException: Could not find a method onStartSingleInstanceActivityClickLisenter(
- Android实战简易教程<五十九>(EventBus小实例-传值、控制其他页控件显示)
- Test Automation Tools
- hadoop小文件问题&解决方案
- 设计模式 适配器模式 以手机充电器为例
- Google I/O 2014 & 2015 之 ART
- Objective-C和JS交互
- Eclipse build Android时不生成apk问题解决方法(已处理)
- QT5主窗体