package zyf.myTest; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class StartingSubactivities extends Activity implements OnClickListener { private Button open; private Intent toIntent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); open=(Button)findViewById(R.id.btn_open _search ); open.setOnClickListener(this); } @ Override public void onClick(View v) { if(v.getId()==R.id.btn_open_search ){ toIntent = new Intent(); toIntent.setClass(StartingSubactivities.this, MySecondActivity.class); startActivity(toIntent); } } }