0
btnPhotoGalary = (Button) findViewById(R.id.btn_photo_galary);
btnPhotoGalary.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        startActivity(new Intent(SplashActivity.this,
                AllPhotoActivity.class));
    }
});


btnInformation = (Button) findViewById(R.id.btn_information);
btnInformation.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        startActivity(new Intent(SplashActivity.this,
                Information.class));
    }
});

此代码用于按钮的单击事件。信息按钮显示在应用程序中,但是当您单击它时,应用程序会自动关闭。为什么?

4

2 回答 2

0

代码看起来不错...

您应该在此处粘贴错误描述。它可以从 DDMS 窗口复制。

清单:

检查清单文件,您是否在 XML 中定义了您的活动?

<activity android:name=".AllPhotoActivity" android:label="Photo Activity Title"> 
</activity>
于 2012-04-06T07:48:58.440 回答
0

尝试

btnPhotoGalary = (Button) findViewById(R.id.btn_photo_galary);
    btnPhotoGalary.setOnClickListener(new View.OnClickListener() {

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


    btnInformation = (Button) findViewById(R.id.btn_information);
    btnInformation.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(this,
                    Information.class));
        }
    });
于 2012-04-06T07:25:48.653 回答