天天看点

android按钮点击属性值,android:onclick属性

android:onclick属性设置点击时从上下文中调用指定的方法。该属性值和要调用的方法名称完全一致。一般在Activity定义符合如下参数和返回值的函数并将方法名字符串指定为该属性值即可:

public void onClickButton(View view)

android:onClick=“onClickButton”

功能类似于Button的监听器。

android:id="@+id/main_login_btn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="@drawable/btn_style_green"

android:text="登录"

android:onClick="welcome_login" />

public void welcome_login(View v) {

Intent intent = new Intent();

intent.setClass(Welcome.this,Login.class);

startActivity(intent);

//this.finish();

}

声明参考:http://www.oschina.net/question/163910_27974