我对下面的代码有疑问,我的欢迎屏幕上有两个按钮。每个按钮链接到不同的页面,我是否使用了错误的代码?大家可以指导我并纠正我吗?我是新的 android 应用程序开发。
package com.example.testing;
    import android.app.Activity;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.Bundle;
    import android.preference.PreferenceManager;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    public class WelcomeActivity extends Activity implements OnClickListener {
        private Boolean firstRun;
        //private Boolean accountRun;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.setContentView(R.layout.welcome);
            SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
            if(sp.getBoolean("firstRun", true)){
                PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
                firstRun = true;
                SharedPreferences.Editor editor = sp.edit();
                editor.putBoolean("firstRun", false);
                editor.commit();
            } else {
                firstRun = false;
            }
            this.initViews();
        }
        private void initViews(){
            Button btnAccount = (Button)this.findViewById(R.id.btnAccount);
            btnAccount.setOnClickListener(this);
            Button btnContinue = (Button)this.findViewById(R.id.btnContinue);
            btnContinue.setOnClickListener(this);
        }
        @Override
        public void onClick(View arg0) {
            Intent i = new Intent(this, testingquestion1.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            i.putExtra("firstRun", firstRun);
            startActivity(i);
            Intent h = new Intent(this, testingquestion2.class);
            //h.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            //i.putExtra("firstRun", firstRun);
            startActivity(h);
        }
    }