(碎片代码)Button事件添加监听器
2017-10-14 10:37
169 查看
安卓 button事件添加监听器
Button button=(Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener(){
public void onClick(View view){
// Intent intent = new Intent(IntentDemoActivity.this, NewActivity.class);
// startActivity(intent);
Intent intent= new Intent(IntentDemoActivity.this,NewActivity.class);
startActivity(intent);
}
});
xml文件格式
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:text="Button" />
Button button=(Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener(){
public void onClick(View view){
// Intent intent = new Intent(IntentDemoActivity.this, NewActivity.class);
// startActivity(intent);
Intent intent= new Intent(IntentDemoActivity.this,NewActivity.class);
startActivity(intent);
}
});
xml文件格式
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:text="Button" />
相关文章推荐
- uGUI使用代码动态添加Button.OnClick()事件
- unity3d canvas button 代码添加鼠标单击/触摸单击触发事件
- 怎样用后台代码添加Button的OnClick事件
- uGUI使用代码动态添加Button.OnClick()事件
- Button 在布局文件中定义监听器,文字阴影,自定义图片,代码绘制样式,添加音效的方法
- UGUI代码添加带参数的Button事件
- ugui使用代码动态添加Button.OnClick()事件
- uGUI使用代码动态添加Button.OnClick()事件(Unity3D开发之十二)
- uGUI使用代码动态添加Button.OnClick()事件(Unity3D开发之十二)
- javascript 动态添加事件代码
- .NET WinFrom中给文本框添加拖放事件的代码
- 在XAML代码中为节点树安装事件监听器
- button按钮用ActionScript添加事件
- Java添加事件监听的四种方法代码实例
- DataGridViewButtonColumn添加单击事件
- Java添加事件监听的四种方法代码实例
- jQuery支持添加事件的日历特效代码分享(3种样式)
- jQuery支持添加事件的日历特效代码分享(3种样式)
- 关于在Android中添加事件监听器的方法