@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));
}
}
/*改代码是转载的*/