|
发表于 2011-10-22 18:46:19
|
显示全部楼层
Re:Q
kerwin2011 的帖子
public class IndexActivity extends Activity {
private Button button_rollcall;//进入系统按钮
private Button button_synchronous;//同步数据按钮
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//获取控件
button_rollcall = (Button)this.findViewById(R.id.button_rollcall);
button_synchronous = (Button)this.findViewById(R.id.button_synchronous);
//注册点击事件
button_rollcall.setOnClickListener(listener);
button_synchronous.setOnClickListener(listener);
}
private View.OnClickListener listener = new OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Button button = (Button) view;//强制转换类型
switch (button.getId()) {
case R.id.button_rollcall : {
Intent intent = new Intent();
intent.setClass(IndexActivity.this, RollCallActivity.class);
startActivity(intent);
}
case R.id.button_synchronous : {
Intent intent = new Intent();
intent.setClass(IndexActivity.this, XmlToDataActivity.class);
startActivity(intent);
}
}
}
};
} |
|