public class Activity02 extends ActionBarActivity {
private Button myButton = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myButton = (Button)findViewById(R.id.myButton);
myButton.setOnClickListener(new MyButtonListener());
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
class MyButtonListener implements Button.OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent= new Intent();
intent.setClass(Activity02.this, OtherActivity.class);
Activity02.this.startActivity(intent);
}
}
}
myButton.setOnClickListener(new MyButtonListener());花线的地报错