@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initUI();


}

private void initUI() {
setContentView(R.layout.main);
findViewById(R.id.toCheckboxSnippetButton).setOnClickListener(
new StartActivityButtonListener(
MultiSelectionAndEditableActivity.
class));
findViewById(R.id.toProgressbarListSnippetButton).setOnClickListener(
new StartActivityButtonListener(ProgressbarListActivity.class));
findViewById(R.id.toPageLoadButton).setOnClickListener(
new StartActivityButtonListener(PageLoadActivity.class));


}

class StartActivityButtonListener implements OnClickListener {
Class
<? extends Activity> targetActivity;

StartActivityButtonListener(Class
<? extends Activity> targetActivity) {
this.targetActivity = targetActivity;
}

@Override
public void onClick(View v) {
startActivity(
new Intent(MainActivity.this, targetActivity));
}

}

/*改代码是转载的*/
posted on 2011-08-18 16:06  QZB  阅读(410)  评论(0编辑  收藏  举报