请耐心等待,因为我只是在学习 Android。我想要做的是当我点击一个按钮时打开一个活动。这是我的主要活动中的代码
public class MainPage extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button restaurants = (Button) findViewById(R.id.widget88);
restaurants.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), AZRestaurants.class);
startActivityForResult(myIntent, 0);
}
});
//Button location = (Button) findViewById(R.id.location);
//location.setOnClickListener(new View.OnClickListener() {
//public void onClick(View view) {
// Intent myIntent = new Intent(view.getContext(), Location.class);
// startActivity(myIntent);
//}
// });
}
当我只实现第一个按钮(餐厅)时,程序启动没有问题。
但是,当我尝试实现已注释掉的按钮时,它无法启动。是的,我已将活动添加到清单文件中。
任何人都可以帮助我吗?
谢谢。