0

どういうわけか、onClickListener を解体したようです。なんらかの理由で、突然 goButton をクリックしても何もしません。私はコードを何度も見直しましたが、ここで間違ったことを見つけられないようです。助言がありますか?

//This activity displays the start layout of the app
    public class StartActivity extends Activity implements OnClickListener {
        private AnimationDrawable mGoButtonAnimation;
        Button goButton;
        Context c;
        boolean isAirPlaneMode, isMDNPresent = false;// boolean values to check for
        // airplane mode and if the
        // sim populates the MDN
        int simState;
        TelephonyManager tm;
        boolean NetworkConnection = false;// boolean to check the Network
        // Availability
        AlertDialog mConfirmAlert = null;
        TextView text;
        TextView mUpdatetext;
        int version;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.start);
            Button goButton = (Button) findViewById(R.id.go_button);
            // Set GO button to drawable animation
            goButton.setBackgroundResource(R.drawable.go_button_animation);
            mGoButtonAnimation = (AnimationDrawable) goButton.getBackground();

            version = android.os.Build.VERSION.SDK_INT;
            tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            // to read the SIM state
            simState = tm.getSimState();
            System.out.println("Sim State" + simState);
            if (tm.getLine1Number() == null) {
                showAlert("Insert an active  SIM.");
            }
            // to check for MDN
            else if (tm.getLine1Number().equalsIgnoreCase("")) {
                isMDNPresent = true;
            }

            String texts = "";
            CharSequence styledText = texts;

            goButton = (Button) findViewById(R.id.go_button);

            text = (TextView) findViewById(R.id.text);

            // text for go button
            texts = String.format(getString(R.string.start_text));

            styledText = Html.fromHtml(texts);

            text.setText(styledText);

            // to check for the network availability
            NetworkConnection = CheckNetworkAvailability
                    .CheckforNetworkAvailability(StartActivity.this);
            if (!NetworkConnection) {
                showAlert("Network is not available, Check for the Network Connections");
            }
            // to check for airplane mode
            isAirPlaneMode = isAirplaneModeOn(StartActivity.this);
            goButton.setOnClickListener(this);

        }

        public void onClick(View v) {
            if (v == goButton) {
                //

                if (simState == TelephonyManager.SIM_STATE_ABSENT) {
                    showAlert("Sim Card is absent, Please insert a   Sim Card");

                } else if (simState == TelephonyManager.SIM_STATE_UNKNOWN) {
                    showAlert("Sim Card is absent, Please insert a   Sim Card");
                } else if (isAirPlaneMode != false) {

                    showAlert("Please Insert a  Sim Card or Turn on the AirPlane Mode and Re-Run the app");

                } else if (simState == TelephonyManager.SIM_STATE_NETWORK_LOCKED
                        || simState == TelephonyManager.SIM_STATE_PIN_REQUIRED
                        || simState == TelephonyManager.SIM_STATE_PUK_REQUIRED
                        || simState == TelephonyManager.SIM_STATE_UNKNOWN) {

                    showAlert("Sim Card is absent, Please insert a  Sim Card");

                } else if (simState == TelephonyManager.SIM_STATE_READY) {
                    if (version < VERSION_CODES.ICE_CREAM_SANDWICH) {// Pre-ICS
                        if (isMDNPresent) {
                            // start SaveMDN activity
                            Intent i = new Intent(StartActivity.this, SaveMDN.class);
                            startActivity(i);
                            finish();
                        } else {
                            // start ActivityForPreICS activity
                            Intent i = new Intent(StartActivity.this,
                                    ActivityForPreICS.class);
                            startActivity(i);
                            finish();
                        }
                    } else {
                        // ICS and UP
                        if (isMDNPresent) {
                            // start SaveMDN activity
                            Intent i = new Intent(StartActivity.this, SaveMDN.class);
                            startActivity(i);
                            finish();
                        } else {
                            // start Update Activity
                            Intent i = new Intent(StartActivity.this,
                                    UpdateActivity.class);
                            startActivity(i);
                            finish();
                        }
                    }
                }

            }

        }
4

1 に答える 1