Example usage for android.text InputType TYPE_CLASS_NUMBER

List of usage examples for android.text InputType TYPE_CLASS_NUMBER

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_NUMBER.

Prototype

int TYPE_CLASS_NUMBER

To view the source code for android.text InputType TYPE_CLASS_NUMBER.

Click Source Link

Document

Class for numeric text.

Usage

From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java

private void editWordCountTextDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.event_word_count_title);

    // Set up the input
    final EditText input = new EditText(getActivity());

    input.setText(mWordCountViewButton.getText());
    input.setSelected(true);/* www  .java 2  s . c  o m*/

    // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    builder.setView(input);

    // Set up the buttons
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mWordCountViewButton.setText(input.getText().toString());
            mWordCount = Integer.parseInt(input.getText().toString());
            mWordCountSeekBar.setProgress(mWordCount);

        }
    });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}

From source file:usbong.android.utils.UsbongScreenProcessor.java

public void init() {
    //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
    Resources myRes = udtea.getResources();
    Drawable myDrawableImage;//w  w  w  .  java 2 s.  c o m

    //added by Mike, Feb. 13, 2013
    udtea.isAnOptionalNode = UsbongUtils.isAnOptionalNode(udtea.currUsbongNode);

    String myStringToken = "";
    //      if (usedBackButton) {

    //        System.out.println(">>>>>> udtea.currAnswer: "+udtea.currAnswer);

    StringTokenizer st = new StringTokenizer(udtea.currAnswer, ",");
    if ((st != null) && (st.hasMoreTokens())) {
        myStringToken = st.nextToken();
        udtea.currAnswer = udtea.currAnswer.replace(myStringToken + ",", "");
    }

    StringTokenizer st_two = new StringTokenizer(udtea.currAnswer, ";");

    if (st_two != null) {
        if (udtea.currAnswer.length() > 1) {
            myStringToken = st_two.nextToken(); //get next element (i.e. 1 in "Y,1;")                
        } else {
            myStringToken = "";
        }
    }

    if (udtea.currScreen == udtea.MULTIPLE_RADIO_BUTTONS_SCREEN) {
        udtea.setContentView(R.layout.multiple_radio_buttons_screen);
        udtea.initBackNextButtons();
        TextView myMultipleRadioButtonsScreenTextView = (TextView) udtea
                .findViewById(R.id.radio_buttons_textview);
        myMultipleRadioButtonsScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myMultipleRadioButtonsScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        RadioGroup radioGroup = (RadioGroup) udtea.findViewById(R.id.multiple_radio_buttons_radiogroup);
        int totalRadioButtonsInContainer = udtea.radioButtonsContainer.size();
        for (int i = 0; i < totalRadioButtonsInContainer; i++) {
            View radioButtonView = new RadioButton(udtea.getBaseContext());
            RadioButton radioButton = (RadioButton) UsbongUtils.applyTagsInView(
                    UsbongDecisionTreeEngineActivity.getInstance(), radioButtonView, UsbongUtils.IS_RADIOBUTTON,
                    udtea.radioButtonsContainer.elementAt(i).toString());
            radioButton.setTextSize(20);
            radioButton.setId(i);
            radioButton.setTextColor(Color.parseColor("#4a452a"));

            int myStringTokenInt;
            try {
                myStringTokenInt = Integer.parseInt(myStringToken);
            } catch (NumberFormatException e) {//if myStringToken is not an int;
                myStringTokenInt = -1;
            }

            if ((!myStringToken.equals("")) && (i == myStringTokenInt)) {
                radioButton.setChecked(true);
            } else {
                radioButton.setChecked(false);
            }

            radioGroup.addView(radioButton);
        }
    } else if (udtea.currScreen == udtea.MULTIPLE_RADIO_BUTTONS_WITH_ANSWER_SCREEN) {
        udtea.setContentView(R.layout.multiple_radio_buttons_screen);
        udtea.initBackNextButtons();
        String myMultipleRadioButtonsWithAnswerScreenStringToken = "";
        //             Log.d(">>>>>>>>udtea.currUsbongNode", udtea.currUsbongNode);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNode.replace("Answer=", "~");
        StringTokenizer myMultipleRadioButtonsWithAnswerScreenStringTokenizer = new StringTokenizer(
                udtea.currUsbongNodeWithoutAnswer, "~");
        if (myMultipleRadioButtonsWithAnswerScreenStringTokenizer != null) {
            myMultipleRadioButtonsWithAnswerScreenStringToken = myMultipleRadioButtonsWithAnswerScreenStringTokenizer
                    .nextToken();

            while (myMultipleRadioButtonsWithAnswerScreenStringTokenizer.hasMoreTokens()) { //get last element (i.e. 0 in "radioButtonsWithAnswer~You see your teacher approaching you. What do you do?Answer=0")
                myMultipleRadioButtonsWithAnswerScreenStringToken = myMultipleRadioButtonsWithAnswerScreenStringTokenizer
                        .nextToken();
            }
        }
        udtea.myMultipleRadioButtonsWithAnswerScreenAnswer = myMultipleRadioButtonsWithAnswerScreenStringToken
                .toString();
        //             Log.d(">>>>>>>>udtea.myMultipleRadioButtonsWithAnswerScreenAnswer", udtea.myMultipleRadioButtonsWithAnswerScreenAnswer);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNodeWithoutAnswer.substring(0,
                udtea.currUsbongNodeWithoutAnswer.length()
                        - udtea.myMultipleRadioButtonsWithAnswerScreenAnswer.length() - 1); //do a -1 for the last tilde             
        //             Log.d(">>>>>>>>udtea.currUsbongNodeWithoutAnswer", udtea.currUsbongNodeWithoutAnswer);
        TextView myMultipleRadioButtonsWithAnswerScreenTextView = (TextView) udtea
                .findViewById(R.id.radio_buttons_textview);
        myMultipleRadioButtonsWithAnswerScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myMultipleRadioButtonsWithAnswerScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNodeWithoutAnswer);
        RadioGroup myMultipleRadioButtonsWithAnswerRadioGroup = (RadioGroup) udtea
                .findViewById(R.id.multiple_radio_buttons_radiogroup);
        int myMultipleRadioButtonsWithAnswerTotalRadioButtonsInContainer = udtea.radioButtonsContainer.size();
        for (int i = 0; i < myMultipleRadioButtonsWithAnswerTotalRadioButtonsInContainer; i++) {
            View radioButtonView = new RadioButton(udtea.getBaseContext());
            RadioButton radioButton = (RadioButton) UsbongUtils.applyTagsInView(
                    UsbongDecisionTreeEngineActivity.getInstance(), radioButtonView, UsbongUtils.IS_RADIOBUTTON,
                    udtea.radioButtonsContainer.elementAt(i).toString());
            radioButton.setTextSize(20);
            radioButton.setId(i);
            radioButton.setTextColor(Color.parseColor("#4a452a"));

            if ((!myStringToken.equals("")) && (i == Integer.parseInt(myStringToken))) {
                radioButton.setChecked(true);
            } else {
                radioButton.setChecked(false);
            }

            myMultipleRadioButtonsWithAnswerRadioGroup.addView(radioButton);
        }
    } else if (udtea.currScreen == udtea.LINK_SCREEN) {
        //use same contentView as multiple_radio_buttons_screen
        udtea.setContentView(R.layout.multiple_radio_buttons_screen);
        udtea.initBackNextButtons();
        TextView myLinkScreenTextView = (TextView) udtea.findViewById(R.id.radio_buttons_textview);
        myLinkScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myLinkScreenTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);

        RadioGroup myLinkScreenRadioGroup = (RadioGroup) udtea
                .findViewById(R.id.multiple_radio_buttons_radiogroup);
        int myLinkScreenTotalRadioButtonsInContainer = udtea.radioButtonsContainer.size();
        for (int i = 0; i < myLinkScreenTotalRadioButtonsInContainer; i++) {
            View radioButtonView = new RadioButton(udtea.getBaseContext());
            RadioButton radioButton = (RadioButton) UsbongUtils.applyTagsInView(
                    UsbongDecisionTreeEngineActivity.getInstance(), radioButtonView, UsbongUtils.IS_RADIOBUTTON,
                    UsbongUtils.trimUsbongNodeName(udtea.radioButtonsContainer.elementAt(i).toString()));

            Log.d(">>>>>radioButton", radioButton.getText().toString());

            //                  radioButton.setChecked(false);
            radioButton.setTextSize(20);
            radioButton.setId(i);
            radioButton.setTextColor(Color.parseColor("#4a452a"));

            if ((!myStringToken.equals("")) && (i == Integer.parseInt(myStringToken))) {
                radioButton.setChecked(true);
            } else {
                radioButton.setChecked(false);
            }

            myLinkScreenRadioGroup.addView(radioButton);
        }
    } else if (udtea.currScreen == udtea.MULTIPLE_CHECKBOXES_SCREEN) {
        udtea.setContentView(R.layout.multiple_checkboxes_screen);
        udtea.initBackNextButtons();
        TextView myMultipleCheckBoxesScreenTextView = (TextView) udtea.findViewById(R.id.checkboxes_textview);
        myMultipleCheckBoxesScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myMultipleCheckBoxesScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        LinearLayout myMultipleCheckboxesLinearLayout = (LinearLayout) udtea
                .findViewById(R.id.multiple_checkboxes_linearlayout);
        int totalCheckBoxesInContainer = udtea.checkBoxesContainer.size();
        StringTokenizer myMultipleCheckboxStringTokenizer = new StringTokenizer(myStringToken, ",");
        Vector<String> myCheckedAnswers = new Vector<String>();
        //             int counter=0;             
        while (myMultipleCheckboxStringTokenizer.countTokens() > 0) {
            String myMultipleCheckboxStringToken = myMultipleCheckboxStringTokenizer.nextToken();
            if (myMultipleCheckboxStringToken != null) {
                myCheckedAnswers.add(myMultipleCheckboxStringToken);
            } else {
                break;
            }
            //                counter++;
        }
        for (int i = 0; i < totalCheckBoxesInContainer; i++) {
            CheckBox checkBox = new CheckBox(udtea.getBaseContext());
            //                  checkBox.setText(StringEscapeUtils.unescapeJava(udtea.checkBoxesContainer.elementAt(i).toString()));
            checkBox = (CheckBox) UsbongUtils.applyTagsInView(UsbongDecisionTreeEngineActivity.getInstance(),
                    checkBox, UsbongUtils.IS_CHECKBOX,
                    StringEscapeUtils.unescapeJava(udtea.checkBoxesContainer.elementAt(i).toString()));

            for (int k = 0; k < myCheckedAnswers.size(); k++) {
                try {
                    if (i == Integer.parseInt(myCheckedAnswers.elementAt(k))) {
                        checkBox.setChecked(true);
                    }
                } catch (NumberFormatException e) {//if myCheckedAnswers.elementAt(k) is not an int;
                    continue;
                }
            }

            checkBox.setTextSize(20);
            checkBox.setTextColor(Color.parseColor("#4a452a"));
            myMultipleCheckboxesLinearLayout.addView(checkBox);
        }
    } else if (udtea.currScreen == udtea.AUDIO_RECORD_SCREEN) {
        udtea.setContentView(R.layout.audio_recorder_screen);
        udtea.initRecordAudioScreen();
        udtea.initBackNextButtons();
        TextView myAudioRecorderTextView = (TextView) udtea.findViewById(R.id.audio_recorder_textview);
        myAudioRecorderTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myAudioRecorderTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        Button recordButton = (Button) udtea.findViewById(R.id.record_button);
        Button stopButton = (Button) udtea.findViewById(R.id.stop_button);
        Button playButton = (Button) udtea.findViewById(R.id.play_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            recordButton.setText((String) udtea.getResources().getText(R.string.UsbongRecordTextViewFILIPINO));
            stopButton.setText((String) udtea.getResources().getText(R.string.UsbongStopTextViewFILIPINO));
            playButton.setText((String) udtea.getResources().getText(R.string.UsbongPlayTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            recordButton.setText((String) udtea.getResources().getText(R.string.UsbongRecordTextViewJAPANESE));
            stopButton.setText((String) udtea.getResources().getText(R.string.UsbongStopTextViewJAPANESE));
            playButton.setText((String) udtea.getResources().getText(R.string.UsbongPlayTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            recordButton.setText((String) udtea.getResources().getText(R.string.UsbongRecordTextViewENGLISH));
            stopButton.setText((String) udtea.getResources().getText(R.string.UsbongStopTextViewENGLISH));
            playButton.setText((String) udtea.getResources().getText(R.string.UsbongPlayTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.PHOTO_CAPTURE_SCREEN) {
        udtea.setContentView(R.layout.photo_capture_screen);
        if (!udtea.performedCapturePhoto) {
            udtea.initTakePhotoScreen();
        }
        udtea.initBackNextButtons();
        TextView myPhotoCaptureScreenTextView = (TextView) udtea.findViewById(R.id.photo_capture_textview);
        myPhotoCaptureScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myPhotoCaptureScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        Button photoCaptureButton = (Button) udtea.findViewById(R.id.photo_capture_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            photoCaptureButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongTakePhotoTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            photoCaptureButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongTakePhotoTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            photoCaptureButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongTakePhotoTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.PAINT_SCREEN) {
        udtea.setContentView(R.layout.paint_screen);
        if (!udtea.performedRunPaint) {
            udtea.initPaintScreen();
        }
        udtea.initBackNextButtons();
        TextView myPaintScreenTextView = (TextView) udtea.findViewById(R.id.paint_textview);
        myPaintScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myPaintScreenTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);
        Button paintButton = (Button) udtea.findViewById(R.id.paint_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            paintButton.setText((String) udtea.getResources().getText(R.string.UsbongRunPaintTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            paintButton.setText((String) udtea.getResources().getText(R.string.UsbongRunPaintTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            paintButton.setText((String) udtea.getResources().getText(R.string.UsbongRunPaintTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.QR_CODE_READER_SCREEN) {
        udtea.setContentView(R.layout.qr_code_reader_screen);
        if (!udtea.performedGetQRCode) {
            udtea.initQRCodeReaderScreen();
        }
        udtea.initBackNextButtons();
        TextView myQRCodeReaderScreenTextView = (TextView) udtea.findViewById(R.id.qr_code_reader_textview);
        myQRCodeReaderScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myQRCodeReaderScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        Button qrCodeReaderButton = (Button) udtea.findViewById(R.id.qr_code_reader_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            qrCodeReaderButton.setText(
                    (String) udtea.getResources().getText(R.string.UsbongQRCodeReaderTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            qrCodeReaderButton.setText(
                    (String) udtea.getResources().getText(R.string.UsbongQRCodeReaderTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            qrCodeReaderButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongQRCodeReaderTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.TEXTFIELD_SCREEN) {
        udtea.setContentView(R.layout.textfield_screen);
        udtea.initBackNextButtons();
        TextView myTextFieldScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myTextFieldScreenEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myTextFieldScreenEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTFIELD_WITH_ANSWER_SCREEN) {
        udtea.setContentView(R.layout.textfield_screen);
        udtea.initBackNextButtons();
        String myTextFieldWithAnswerScreenStringToken = "";
        //             Log.d(">>>>>>>>udtea.currUsbongNode", udtea.currUsbongNode);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNode.replace("Answer=", "~");
        StringTokenizer myTextFieldWithAnswerScreenStringTokenizer = new StringTokenizer(
                udtea.currUsbongNodeWithoutAnswer, "~");
        if (myTextFieldWithAnswerScreenStringTokenizer != null) {
            myTextFieldWithAnswerScreenStringToken = myTextFieldWithAnswerScreenStringTokenizer.nextToken();

            while (myTextFieldWithAnswerScreenStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textFieldWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike")
                myTextFieldWithAnswerScreenStringToken = myTextFieldWithAnswerScreenStringTokenizer.nextToken();
            }
        }
        udtea.myTextFieldWithAnswerScreenAnswer = myTextFieldWithAnswerScreenStringToken.toString();
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNodeWithoutAnswer.substring(0,
                udtea.currUsbongNodeWithoutAnswer.length() - udtea.myTextFieldWithAnswerScreenAnswer.length()
                        - 1); //do a -1 for the last tilde             
        TextView myTextFieldWithAnswerScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldWithAnswerScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldWithAnswerScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNodeWithoutAnswer);
        EditText myTextFieldScreenWithAnswerEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myTextFieldScreenWithAnswerEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTAREA_SCREEN) {
        udtea.setContentView(R.layout.textarea_screen);
        udtea.initBackNextButtons();
        TextView myTextAreaScreenTextView = (TextView) udtea.findViewById(R.id.textarea_textview);
        myTextAreaScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextAreaScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myTextAreaScreenEditText = (EditText) udtea.findViewById(R.id.textarea_edittext);
        myTextAreaScreenEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTAREA_WITH_ANSWER_SCREEN) {
        udtea.setContentView(R.layout.textarea_screen);
        udtea.initBackNextButtons();
        String myTextAreaWithAnswerScreenStringToken = "";
        //             Log.d(">>>>>>>>udtea.currUsbongNode", udtea.currUsbongNode);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNode.replace("Answer=", "~");
        StringTokenizer myTextAreaWithAnswerScreenStringTokenizer = new StringTokenizer(
                udtea.currUsbongNodeWithoutAnswer, "~");
        if (myTextAreaWithAnswerScreenStringTokenizer != null) {
            myTextAreaWithAnswerScreenStringToken = myTextAreaWithAnswerScreenStringTokenizer.nextToken();

            while (myTextAreaWithAnswerScreenStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textFieldWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike")
                myTextAreaWithAnswerScreenStringToken = myTextAreaWithAnswerScreenStringTokenizer.nextToken();
            }
        }
        udtea.myTextAreaWithAnswerScreenAnswer = myTextAreaWithAnswerScreenStringToken.toString();
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNodeWithoutAnswer.substring(0,
                udtea.currUsbongNodeWithoutAnswer.length() - udtea.myTextAreaWithAnswerScreenAnswer.length()
                        - 1); //do a -1 for the last tilde             
        TextView myTextAreaWithAnswerScreenTextView = (TextView) udtea.findViewById(R.id.textarea_textview);
        myTextAreaWithAnswerScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextAreaWithAnswerScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNodeWithoutAnswer);
        EditText myTextAreaScreenWithAnswerEditText = (EditText) udtea.findViewById(R.id.textarea_edittext);
        myTextAreaScreenWithAnswerEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTFIELD_WITH_UNIT_SCREEN) {
        udtea.setContentView(R.layout.textfield_with_unit_screen);
        udtea.initBackNextButtons();
        TextView myTextFieldWithUnitScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldWithUnitScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldWithUnitScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        myEditText.setText(myStringToken);
        TextView myUnitScreenTextView = (TextView) udtea.findViewById(R.id.textfieldunit_textview);
        myUnitScreenTextView.setText(udtea.textFieldUnit);
    } else if (udtea.currScreen == udtea.TEXTFIELD_NUMERICAL_SCREEN) {
        udtea.setContentView(R.layout.textfield_screen);
        udtea.initBackNextButtons();
        TextView myTextFieldNumericalScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldNumericalScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldNumericalScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myTextFieldNumericalScreenEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myTextFieldNumericalScreenEditText
                .setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        myTextFieldNumericalScreenEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.CLASSIFICATION_SCREEN) {
        udtea.setContentView(R.layout.classification_screen);
        udtea.initBackNextButtons();
        TextView myClassificationScreenTextView = (TextView) udtea.findViewById(R.id.classification_textview);
        myClassificationScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myClassificationScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        LinearLayout myClassificationLinearLayout = (LinearLayout) udtea
                .findViewById(R.id.classification_linearlayout);
        int totalClassificationsInContainer = udtea.classificationContainer.size();
        for (int i = 0; i < totalClassificationsInContainer; i++) {
            TextView myTextView = new TextView(udtea.getBaseContext());
            //consider removing this code below; not needed; Mike, May 23, 2013
            myTextView = (TextView) UsbongUtils.applyTagsInView(UsbongDecisionTreeEngineActivity.getInstance(),
                    myTextView, UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);

            int bulletCount = i + 1;
            if (UsbongUtils.USE_UNESCAPE) {
                myTextView.setText(bulletCount + ") " + StringEscapeUtils
                        .unescapeJava(udtea.classificationContainer.elementAt(i).toString()));
            } else {
                myTextView.setText(bulletCount + ") " + UsbongUtils
                        .trimUsbongNodeName(udtea.classificationContainer.elementAt(i).toString()));
            }

            //add 5 so that the text does not touch the left border
            myTextView.setPadding(udtea.padding_in_px, 0, 0, 0);
            myTextView.setTextSize(24);
            //                 myTextView.setTextColor(Color.WHITE);
            myTextView.setTextColor(Color.parseColor("#4a452a"));
            myClassificationLinearLayout.addView(myTextView);
        }
    } else if (udtea.currScreen == udtea.DCAT_SUMMARY_SCREEN) {
        udtea.setContentView(R.layout.dcat_summary_screen);
        udtea.initBackNextButtons();
        TextView myDCATSummaryScreenTextView = (TextView) udtea.findViewById(R.id.dcat_summary_textview);
        myDCATSummaryScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myDCATSummaryScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        udtea.myDcatSummaryStringBuffer = new StringBuffer();
        String weightsString = "1.9;2.1;2.6;1.8;2.4;1.8;.7;1.0;1.6;2.6;6.9;5.7;3.3;2.2;3.3;3.3;2;2;1.7;1.9;3.9;1.3;2.5;.8";
        StringTokenizer myWeightsStringTokenizer = new StringTokenizer(weightsString, ";");
        String myWeightString = myWeightsStringTokenizer.nextToken();
        //            
        //            while (st.hasMoreTokens()) {
        //               myStringToken = st.nextToken(); 
        //            }
        //
        double myWeightedScoreInt = 0;
        double myNegotiatedWeightedScoreInt = 0;
        double[][] dcatSum = new double[8][4];
        final int sumWeightedRatingIndex = 0;
        final int sumWeightedScoreIndex = 1;
        final int sumNegotiatedRatingIndex = 2;
        final int sumNegotiatedScoreIndex = 3;
        int currStandard = 0;//standard 1
        //            boolean hasReachedNegotiated=false;
        boolean hasReachedStandardTotal = false;
        LinearLayout myDCATSummaryLinearLayout = (LinearLayout) udtea
                .findViewById(R.id.dcat_summary_linearlayout);
        int totalElementsInDCATSummaryBasedOnUsbongNodeContainer = udtea.usbongNodeContainer.size();
        //              for (int i=0; i<totalElementsInDCATSummaryBasedOnUsbongNodeContainer.usbongNodeContainer; i++) {                 
        for (int i = 0; i < totalElementsInDCATSummaryBasedOnUsbongNodeContainer; i++) {

            TextView myTextView = new TextView(udtea.getBaseContext());
            myTextView.setPadding(udtea.padding_in_px, 0, 0, 0); //add 5 so that the text does not touch the left border
            myTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
            myTextView.setTextColor(Color.parseColor("#4a452a"));

            //the only way to check if the element is already the last item in the standard
            //is if the next element in the node container has "STANDARD", but not the first standard
            if ((i + 1 >= totalElementsInDCATSummaryBasedOnUsbongNodeContainer) || (i
                    + 1 < totalElementsInDCATSummaryBasedOnUsbongNodeContainer)
                    && ((udtea.usbongNodeContainer.elementAt(i + 1).toString().contains("STANDARD")))
                    && (!(udtea.usbongNodeContainer.elementAt(i + 1).toString().contains("STANDARD ONE")))) {
                int tempCurrStandard = currStandard + 1; //do a +1 since currStandard begins at 0

                TextView myIssuesTextView = new TextView(udtea.getBaseContext());

                //added by Mike, May 31, 2013
                if (!udtea.usbongAnswerContainer.elementAt(i).toString().contains("dcat_end,")) {

                    String s = udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", "");
                    s = s.replace("A,", "");
                    if (!s.equals("")) {
                        myIssuesTextView = (TextView) UsbongUtils.applyTagsInView(
                                UsbongDecisionTreeEngineActivity.getInstance(), myIssuesTextView,
                                UsbongUtils.IS_TEXTVIEW, "ISSUES: " + s + "{br}");
                    } else {
                        myIssuesTextView = (TextView) UsbongUtils.applyTagsInView(
                                UsbongDecisionTreeEngineActivity.getInstance(), myIssuesTextView,
                                UsbongUtils.IS_TEXTVIEW, "ISSUES: none{br}");
                    }

                    myIssuesTextView.setPadding(udtea.padding_in_px, 0, 0, 0); //add 5 so that the text does not touch the left border
                    myIssuesTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
                    myIssuesTextView.setTextColor(Color.parseColor("#4a452a"));
                    myDCATSummaryLinearLayout.addView(myIssuesTextView);
                    udtea.myDcatSummaryStringBuffer.append(myIssuesTextView.getText().toString() + "\n");
                }

                if (myWeightsStringTokenizer.hasMoreElements()) {
                    //get the next weight
                    myWeightString = myWeightsStringTokenizer.nextToken();
                }

                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        "//--------------------" + " STANDARD " + tempCurrStandard + " (TOTAL){br}"
                                + "Total (Rating): "
                                + String.format("%.2f", dcatSum[currStandard][sumWeightedRatingIndex]) + "{br}"
                                + "Total (Weighted Score): "
                                + String.format("%.2f", dcatSum[currStandard][sumWeightedScoreIndex]) + "{br}"
                                + "Total (Negotiated Rating): "
                                + String.format("%.2f", dcatSum[currStandard][sumNegotiatedRatingIndex])
                                + "{br}" + "Total (Negotiated WS): "
                                + String.format("%.2f", dcatSum[currStandard][sumNegotiatedScoreIndex]) + "{br}"
                                + "//--------------------");
                hasReachedStandardTotal = true;
                currStandard++;
            }

            if (hasReachedStandardTotal) {
                hasReachedStandardTotal = false;
            } else if (udtea.usbongNodeContainer.elementAt(i).toString().contains("ISSUES")) {
                String s = udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", "");
                s = s.replace("A,", "");
                if (!s.equals("")) {
                    myTextView = (TextView) UsbongUtils.applyTagsInView(
                            UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                            "ISSUES: " + s + "{br}");
                } else {
                    myTextView = (TextView) UsbongUtils.applyTagsInView(
                            UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                            "ISSUES: none{br}");
                }

                if (myWeightsStringTokenizer.hasMoreElements()) {
                    //get the next weight
                    myWeightString = myWeightsStringTokenizer.nextToken();
                }
            } else if (udtea.usbongNodeContainer.elementAt(i).toString().contains("Weighted")) {
                TextView myWeightedTextView = new TextView(udtea.getBaseContext());
                myWeightedTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myWeightedTextView,
                        UsbongUtils.IS_TEXTVIEW,
                        udtea.usbongNodeContainer.elementAt(i).toString().replace("{br}(Weighted Score)", ""));
                myWeightedTextView.setPadding(udtea.padding_in_px, 0, 0, 0); //add 5 so that the text does not touch the left border
                myWeightedTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
                myWeightedTextView.setTextColor(Color.parseColor("#4a452a"));

                myDCATSummaryLinearLayout.addView(myWeightedTextView);
                udtea.myDcatSummaryStringBuffer.append(myWeightedTextView.getText().toString() + "\n");

                int weightedAnswer;
                //added by Mike, July 8, 2013
                try {
                    weightedAnswer = Integer
                            .parseInt(udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", ""));
                } catch (Exception e) { //if there's no answer selected
                    weightedAnswer = 0;
                }
                if (weightedAnswer <= 0) {
                    weightedAnswer = 0;
                }

                //the weight is in double
                myWeightedScoreInt = weightedAnswer * Double.parseDouble(myWeightString);
                if (myWeightedScoreInt <= 0) {
                    myWeightedScoreInt = 0;
                    myTextView.setBackgroundColor(Color.YELLOW);
                }

                dcatSum[currStandard][sumWeightedRatingIndex] += weightedAnswer;
                dcatSum[currStandard][sumWeightedScoreIndex] += myWeightedScoreInt;

                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        "Weighted: " + myWeightedScoreInt);
            } else if (udtea.usbongNodeContainer.elementAt(i).toString().contains("Negotiated")) {
                //added by Mike, July 8, 2013
                int negotiatedAnswer;
                try {
                    negotiatedAnswer = Integer
                            .parseInt(udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", ""));
                } catch (Exception e) { //if there's no answer selected
                    negotiatedAnswer = 0;
                }
                if (negotiatedAnswer <= 0) {
                    negotiatedAnswer = 0;
                }

                //the weight is in double
                myNegotiatedWeightedScoreInt = negotiatedAnswer * Double.parseDouble(myWeightString);
                if (myNegotiatedWeightedScoreInt <= 0) {
                    myNegotiatedWeightedScoreInt = 0;
                    myTextView.setBackgroundColor(Color.YELLOW);
                }

                dcatSum[currStandard][sumNegotiatedRatingIndex] += negotiatedAnswer;
                dcatSum[currStandard][sumNegotiatedScoreIndex] += myNegotiatedWeightedScoreInt;

                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        "Negotiated: " + myNegotiatedWeightedScoreInt);
                //                    hasReachedNegotiated=true;
            } else {
                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        udtea.usbongNodeContainer.elementAt(i).toString() + "{br}");
            }

            //                 if (!hasReachedStandardTotal) {
            myDCATSummaryLinearLayout.addView(myTextView);
            udtea.myDcatSummaryStringBuffer.append(myTextView.getText().toString() + "\n");
            Log.d(">>>>>myTextView.getText().toString()", myTextView.getText().toString());
            //                 }
            //                 else {
            //                    hasReachedStandardTotal=false;
            //                 }
        }
    } else if (udtea.currScreen == udtea.DATE_SCREEN) {
        udtea.setContentView(R.layout.date_screen);
        udtea.initBackNextButtons();
        TextView myDateScreenTextView = (TextView) udtea.findViewById(R.id.date_textview);
        myDateScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myDateScreenTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);
        //Reference: http://code.google.com/p/android/issues/detail?id=2037
        //last accessed: 21 Aug. 2012
        Configuration userConfig = new Configuration();
        Settings.System.getConfiguration(udtea.getContentResolver(), userConfig);
        Calendar date = Calendar.getInstance(userConfig.locale);
        //Reference: http://www.androidpeople.com/android-spinner-default-value;
        //last accessed: 21 Aug. 2012              
        //month-------------------------------
        int month = date.get(Calendar.MONTH); //first month of the year is 0
        Spinner dateMonthSpinner = (Spinner) udtea.findViewById(R.id.date_month_spinner);
        udtea.monthAdapter = ArrayAdapter.createFromResource(((Activity) udtea), R.array.months_array,
                android.R.layout.simple_spinner_item);
        //              udtea.monthAdapter  = ArrayAdapter.createFromResource(
        //                this, R.array.months_array, R.layout.date_textview);
        udtea.monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        dateMonthSpinner.setAdapter(udtea.monthAdapter);
        dateMonthSpinner.setSelection(month);
        //              System.out.println(">>>>>>>>>>>>>> month"+month);
        //              Log.d(">>>>>>myStringToken",myStringToken);
        for (int i = 0; i < udtea.monthAdapter.getCount(); i++) {
            //                 Log.d(">>>>>>udtea.monthAdapter ",udtea.monthAdapter .getItem(i).toString());

            if (myStringToken.contains(udtea.monthAdapter.getItem(i).toString())) {
                dateMonthSpinner.setSelection(i);

                //added by Mike, March 4, 2013
                myStringToken = myStringToken.replace(udtea.monthAdapter.getItem(i).toString(), "");
            }
        }
        //-------------------------------------
        //day----------------------------------
        //Reference: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html#MONTH
        //last accessed: 21 Aug 2012
        int day = date.get(Calendar.DAY_OF_MONTH); //first day of the month is 1
        day = day - 1; //do this to offset, when retrieving the day in strings.xml
        Spinner dateDaySpinner = (Spinner) udtea.findViewById(R.id.date_day_spinner);
        udtea.dayAdapter = ArrayAdapter.createFromResource(((Activity) udtea), R.array.day_array,
                android.R.layout.simple_spinner_item);
        udtea.dayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        dateDaySpinner.setAdapter(udtea.dayAdapter);
        dateDaySpinner.setSelection(day);
        //              System.out.println(">>>>>>>>>>>>>> day"+day);
        //              Log.d(">>>>>myStringToken",myStringToken);
        //              System.out.println(">>>>>>>> myStringToken"+myStringToken);
        StringTokenizer myDateStringTokenizer = new StringTokenizer(myStringToken, ",");
        String myDayStringToken = "";
        if (!myStringToken.equals("")) {
            myDayStringToken = myDateStringTokenizer.nextToken();
        }
        for (int i = 0; i < udtea.dayAdapter.getCount(); i++) {
            if (myDayStringToken.contains(udtea.dayAdapter.getItem(i).toString())) {
                dateDaySpinner.setSelection(i);

                myStringToken = myStringToken.replace(udtea.dayAdapter.getItem(i).toString() + ",", "");
                //                    System.out.println(">>>>>>>>>>>myStringToken: "+myStringToken);
            }
        }
        //-------------------------------------            
        //year---------------------------------
        int year = date.get(Calendar.YEAR);
        EditText myDateYearEditText = (EditText) udtea.findViewById(R.id.date_edittext);
        myDateYearEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        //added by Mike, March 4, 2013
        if (myStringToken.equals("")) {
            myDateYearEditText.setText("" + year);
        } else {
            myDateYearEditText.setText(myStringToken);
        }
    } else if (udtea.currScreen == udtea.TEXT_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.text_display_screen);
        udtea.initBackNextButtons();
        TextView myTextDisplayScreenTextView = (TextView) udtea.findViewById(R.id.text_display_textview);
        myTextDisplayScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextDisplayScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);

        //         Log.d(">>>>>","inside udtea.currScreen == udtea.TEXT_DISPLAY_SCREEN");
        //         myTextDisplayScreenTextView = (TextView) UsbongUtils.applyHintsInView(UsbongDecisionTreeEngineActivity.getInstance(), myTextDisplayScreenTextView, UsbongUtils.IS_TEXTVIEW);
        //         Log.d(">>>>>","after myTextDisplayScreenTextView");

    } else if (udtea.currScreen == udtea.TIMESTAMP_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.timestamp_display_screen);
        udtea.initBackNextButtons();
        TextView myTimeDisplayScreenTextView = (TextView) udtea.findViewById(R.id.time_display_textview);
        udtea.timestampString = UsbongUtils.getCurrTimeStamp();
        myTimeDisplayScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTimeDisplayScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode + "{br}" + udtea.timestampString);

    } else if (udtea.currScreen == udtea.SIMPLE_ENCRYPT_SCREEN) {
        udtea.setContentView(R.layout.simple_encrypt_screen);
        udtea.initBackNextButtons();
        TextView myEncryptScreenTextView = (TextView) udtea.findViewById(R.id.encrypt_textview);
        myEncryptScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myEncryptScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);

        String message = "";
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            message = (String) udtea.getResources().getText(R.string.UsbongEncryptAlertMessageFILIPINO);
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            message = (String) udtea.getResources().getText(R.string.UsbongEncryptAlertMessageJAPANESE);
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            message = (String) udtea.getResources().getText(R.string.UsbongEncryptAlertMessageENGLISH);
        }

        new AlertDialog.Builder(udtea).setTitle("Hey!").setMessage(message)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();

    } else if (udtea.currScreen == udtea.IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.image_display_screen);
        udtea.initBackNextButtons();
        ImageView myImageDisplayScreenImageView = (ImageView) udtea.findViewById(R.id.special_imageview);
        //              if (!UsbongUtils.setImageDisplay(myImageDisplayScreenImageView, myTree+".utree/res/" +UsbongUtils.getResName(udtea.currUsbongNode))) {
        if (!UsbongUtils.setImageDisplay(myImageDisplayScreenImageView, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myImageDisplayScreenImageView.setImageDrawable(myDrawableImage);
        }
    } else if (udtea.currScreen == udtea.CLICKABLE_IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.clickable_image_display_screen);
        udtea.initBackNextButtons();
        ImageButton myClickableImageDisplayScreenImageButton = (ImageButton) udtea
                .findViewById(R.id.clickable_image_display_imagebutton);
        if (!UsbongUtils.setClickableImageDisplay(myClickableImageDisplayScreenImageButton, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myClickableImageDisplayScreenImageButton.setBackgroundDrawable(myDrawableImage);
        }
        myClickableImageDisplayScreenImageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //                      myMessage = UsbongUtils.applyTagsInString(udtea.currUsbongNode).toString();                   

                TextView tv = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(),
                        new TextView(UsbongDecisionTreeEngineActivity.getInstance()), UsbongUtils.IS_TEXTVIEW,
                        udtea.currUsbongNode);
                if (tv.toString().equals("")) {
                    tv.setText("No message.");
                }
                tv.setTextSize((UsbongDecisionTreeEngineActivity.getInstance().getResources()
                        .getDimension(R.dimen.textsize)));

                new AlertDialog.Builder(udtea).setTitle("Hey!")
                        //                     .setMessage(myMessage)
                        .setView(tv).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        });
    } else if (udtea.currScreen == udtea.TEXT_CLICKABLE_IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.text_clickable_image_display_screen);
        udtea.initBackNextButtons();
        TextView myTextClickableImageDisplayTextView = (TextView) udtea
                .findViewById(R.id.text_clickable_image_display_textview);
        myTextClickableImageDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextClickableImageDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageButton myTextClickableImageDisplayScreenImageButton = (ImageButton) udtea
                .findViewById(R.id.clickable_image_display_imagebutton);
        if (!UsbongUtils.setClickableImageDisplay(myTextClickableImageDisplayScreenImageButton, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myTextClickableImageDisplayScreenImageButton.setBackgroundDrawable(myDrawableImage);
        }
        myTextClickableImageDisplayScreenImageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //                      myMessage = UsbongUtils.applyTagsInString(udtea.currUsbongNode).toString();                   

                TextView tv = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), new TextView(udtea),
                        UsbongUtils.IS_TEXTVIEW, UsbongUtils.getAlertName(udtea.currUsbongNode));
                if (tv.toString().equals("")) {
                    tv.setText("No message.");
                }
                tv.setTextSize((UsbongDecisionTreeEngineActivity.getInstance().getResources()
                        .getDimension(R.dimen.textsize)));

                new AlertDialog.Builder(udtea).setTitle("Hey!")
                        //                     .setMessage(myMessage)
                        .setView(tv).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        });
    } else if (udtea.currScreen == udtea.CLICKABLE_IMAGE_TEXT_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.clickable_image_text_display_screen);
        udtea.initBackNextButtons();
        TextView myClickableImageTextDisplayTextView = (TextView) udtea
                .findViewById(R.id.clickable_image_text_display_textview);
        myClickableImageTextDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myClickableImageTextDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageButton myClickableImageTextDisplayScreenImageButton = (ImageButton) udtea
                .findViewById(R.id.clickable_image_display_imagebutton);
        if (!UsbongUtils.setClickableImageDisplay(myClickableImageTextDisplayScreenImageButton, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myClickableImageTextDisplayScreenImageButton.setBackgroundDrawable(myDrawableImage);
        }
        myClickableImageTextDisplayScreenImageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //                      myMessage = UsbongUtils.applyTagsInString(udtea.currUsbongNode).toString();                   

                TextView tv = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), new TextView(udtea),
                        UsbongUtils.IS_TEXTVIEW, UsbongUtils.getAlertName(udtea.currUsbongNode));
                if (tv.toString().equals("")) {
                    tv.setText("No message.");
                }
                tv.setTextSize((UsbongDecisionTreeEngineActivity.getInstance().getResources()
                        .getDimension(R.dimen.textsize)));

                new AlertDialog.Builder(udtea).setTitle("Hey!")
                        //                     .setMessage(myMessage)
                        .setView(tv).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        });
    } else if (udtea.currScreen == udtea.VIDEO_FROM_FILE_SCREEN) {
        udtea.setContentView(R.layout.video_from_file_screen);
        udtea.initBackNextButtons();
        VideoView myVideoFromFileScreenVideoView = (VideoView) udtea
                .findViewById(R.id.video_from_file_videoview);
        myVideoFromFileScreenVideoView.setVideoPath(
                UsbongUtils.getPathOfVideoFile(udtea.myTree, UsbongUtils.getResName(udtea.currUsbongNode)));
        //added by Mike, Sept. 9, 2013
        myVideoFromFileScreenVideoView.setMediaController(new MediaController(((Activity) udtea)));
        myVideoFromFileScreenVideoView.start();
    } else if (udtea.currScreen == udtea.VIDEO_FROM_FILE_WITH_TEXT_SCREEN) {
        udtea.setContentView(R.layout.video_from_file_with_text_screen);
        udtea.initBackNextButtons();
        TextView myVideoFromFileWithTextTextView = (TextView) udtea
                .findViewById(R.id.video_from_file_with_text_textview);
        myVideoFromFileWithTextTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myVideoFromFileWithTextTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        VideoView myVideoFromFileWithTextScreenVideoView = (VideoView) udtea
                .findViewById(R.id.video_from_file_with_text_videoview);
        myVideoFromFileWithTextScreenVideoView.setVideoPath(
                UsbongUtils.getPathOfVideoFile(udtea.myTree, UsbongUtils.getResName(udtea.currUsbongNode)));
        myVideoFromFileWithTextScreenVideoView.setMediaController(new MediaController(((Activity) udtea)));
        myVideoFromFileWithTextScreenVideoView.start();
    } else if (udtea.currScreen == udtea.TEXT_IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.text_image_display_screen);
        udtea.initBackNextButtons();
        TextView myTextImageDisplayTextView = (TextView) udtea.findViewById(R.id.text_image_display_textview);
        myTextImageDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextImageDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageView myTextImageDisplayImageView = (ImageView) udtea.findViewById(R.id.image_display_imageview);
        //              if (!UsbongUtils.setImageDisplay(myTextImageDisplayImageView, myTree+".utree/res/" +UsbongUtils.getResName(udtea.currUsbongNode))) {
        if (!UsbongUtils.setImageDisplay(myTextImageDisplayImageView, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myTextImageDisplayImageView.setImageDrawable(myDrawableImage);
        }
    } else if (udtea.currScreen == udtea.IMAGE_TEXT_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.image_text_display_screen);
        udtea.initBackNextButtons();
        TextView myImageTextDisplayTextView = (TextView) udtea.findViewById(R.id.image_text_display_textview);
        myImageTextDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myImageTextDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageView myImageTextDisplayImageView = (ImageView) udtea.findViewById(R.id.image_display_imageview);

        if (!UsbongUtils.setImageDisplay(myImageTextDisplayImageView, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myImageTextDisplayImageView.setImageDrawable(myDrawableImage);
        }
    } else if (udtea.currScreen == udtea.GPS_LOCATION_SCREEN) {
        udtea.setContentView(R.layout.gps_location_screen);
        udtea.initBackNextButtons();
        TextView myGPSLocationTextView = (TextView) udtea.findViewById(R.id.gps_location_textview);
        myGPSLocationTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myGPSLocationTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);
        //         TextView myLongitudeTextView = (TextView)udtea.findViewById(R.id.longitude_textview);
        //         TextView myLatitudeTextView = (TextView)udtea.findViewById(R.id.latitude_textview);
        hasGottenGPSLocation = false;

        locationResult = new LocationResult() {
            @Override
            public void gotLocation(Location location) {
                //Got the location!
                System.out.println(">>>>>>>>>>>>>>>>>location: " + location);
                if (udtea.currScreen == udtea.GPS_LOCATION_SCREEN) {
                    if (location != null) {
                        myLongitude = location.getLongitude() + "";
                        myLatitude = location.getLatitude() + "";

                        myLongitudeTextView = (TextView) udtea.findViewById(R.id.longitude_textview);
                        myLatitudeTextView = (TextView) udtea.findViewById(R.id.latitude_textview);

                        hasGottenGPSLocation = true;

                        udtea.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                myLongitudeTextView.setText("long: " + myLongitude);
                                myLatitudeTextView.setText("lat: " + myLatitude);
                            }
                        });
                    } else {
                        Toast.makeText(UsbongDecisionTreeEngineActivity.getInstance(),
                                "Error getting location. Please make sure you are not inside a building.",
                                Toast.LENGTH_SHORT).show();
                    }
                } else {
                    hasGottenGPSLocation = true; //to stop the cycling progress bar
                }
            }
        };
        //         myLoadingProgressBar =  new ProgressBar(udtea);
        //         myLoadingProgressBar.setIndeterminate(false);
        //         myLoadingProgressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);         

        udtea.myLocation = new FedorMyLocation();
        udtea.myLocation.getLocation(udtea, locationResult);

        myLoadingProgressBar = (ProgressBar) udtea.findViewById(R.id.progressBar);
        new ProgressTask().execute();

    } else if (udtea.currScreen == udtea.YES_NO_DECISION_SCREEN) {
        udtea.setContentView(R.layout.yes_no_decision_screen);
        udtea.initBackNextButtons();
        TextView myYesNoDecisionScreenTextView = (TextView) udtea.findViewById(R.id.yes_no_decision_textview);
        myYesNoDecisionScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myYesNoDecisionScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        RadioButton myYesRadioButton = (RadioButton) udtea.findViewById(R.id.yes_radiobutton);
        myYesRadioButton.setText(udtea.yesStringValue);
        myYesRadioButton.setTextSize(20);
        RadioButton myNoRadioButton = (RadioButton) udtea.findViewById(R.id.no_radiobutton);
        myNoRadioButton.setText(udtea.noStringValue);
        myNoRadioButton.setTextSize(20);
        if (myStringToken.equals("N")) {
            myNoRadioButton.setChecked(true);
        } else if ((myStringToken.equals("Y"))) {
            myYesRadioButton.setChecked(true);
        }
    } else if (udtea.currScreen == udtea.SEND_TO_CLOUD_BASED_SERVICE_SCREEN) {
        udtea.setContentView(R.layout.yes_no_decision_screen);
        udtea.initBackNextButtons();
        TextView mySendToCloudBasedServiceScreenTextView = (TextView) udtea
                .findViewById(R.id.yes_no_decision_textview);
        mySendToCloudBasedServiceScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), mySendToCloudBasedServiceScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        RadioButton mySendToCloudBasedServiceScreenYesRadioButton = (RadioButton) udtea
                .findViewById(R.id.yes_radiobutton);
        mySendToCloudBasedServiceScreenYesRadioButton.setText(udtea.yesStringValue);
        mySendToCloudBasedServiceScreenYesRadioButton.setTextSize(20);
        RadioButton mySendToCloudBasedServiceScreenNoRadioButton = (RadioButton) udtea
                .findViewById(R.id.no_radiobutton);
        mySendToCloudBasedServiceScreenNoRadioButton.setText(udtea.noStringValue);
        mySendToCloudBasedServiceScreenNoRadioButton.setTextSize(20);
        if (myStringToken.equals("N")) {
            mySendToCloudBasedServiceScreenNoRadioButton.setChecked(true);
        } else if ((myStringToken.equals("Y"))) {
            mySendToCloudBasedServiceScreenYesRadioButton.setChecked(true);
        }
    } else if (udtea.currScreen == udtea.SEND_TO_WEBSERVER_SCREEN) {
        udtea.setContentView(R.layout.send_to_webserver_screen);
        udtea.initBackNextButtons();
        TextView mySendToWebserverScreenTextView = (TextView) udtea
                .findViewById(R.id.send_to_webserver_textview);
        mySendToWebserverScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), mySendToWebserverScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        TextView myWebserverURLScreenTextView = (TextView) udtea.findViewById(R.id.webserver_url_textview);

        if (!UsbongUtils.getDestinationServerURL().toString().equals("")) {
            myWebserverURLScreenTextView.setText("[" + UsbongUtils.getDestinationServerURL() + "]");
        } else {
            myWebserverURLScreenTextView.setText("[Warning: No URL specified in Settings.]");
        }

        RadioButton mySendToWebserverYesRadioButton = (RadioButton) udtea.findViewById(R.id.yes_radiobutton);
        mySendToWebserverYesRadioButton.setText(udtea.yesStringValue);
        mySendToWebserverYesRadioButton.setTextSize(20);
        RadioButton mySendToWebserverNoRadioButton = (RadioButton) udtea.findViewById(R.id.no_radiobutton);
        mySendToWebserverNoRadioButton.setText(udtea.noStringValue);
        mySendToWebserverNoRadioButton.setTextSize(20);
        if (myStringToken.equals("N")) {
            mySendToWebserverNoRadioButton.setChecked(true);
        } else if ((myStringToken.equals("Y"))) {
            mySendToWebserverYesRadioButton.setChecked(true);
        }
    } else if (udtea.currScreen == udtea.END_STATE_SCREEN) {
        udtea.setContentView(R.layout.end_state_screen);
        TextView endStateTextView = (TextView) udtea.findViewById(R.id.end_state_textview);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            endStateTextView
                    .setText((String) udtea.getResources().getText(R.string.UsbongEndStateTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            endStateTextView
                    .setText((String) udtea.getResources().getText(R.string.UsbongEndStateTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            endStateTextView
                    .setText((String) udtea.getResources().getText(R.string.UsbongEndStateTextViewENGLISH));
        }
        udtea.initBackNextButtons();
    }
    View myLayout = udtea.findViewById(R.id.parent_layout_id);
    if (!UsbongUtils.setBackgroundImage(myLayout, udtea.myTree, "bg")) {
        myLayout.setBackgroundResource(R.drawable.bg);//default bg
    }

    if ((!udtea.usedBackButton) && (!udtea.hasReturnedFromAnotherActivity)) {
        udtea.usbongNodeContainer.addElement(udtea.currUsbongNode);
        udtea.usbongNodeContainerCounter++;
    } else {
        udtea.usedBackButton = false;
        udtea.hasReturnedFromAnotherActivity = false;
    }
}

From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java

private void showGoToDialog() {
    Context context = getContext2();
    if (null == context || null == mHelper) {
        return;/*from w  ww.  j ava2s.  com*/
    }

    final int page = mHelper.getPageForTop();
    final int pages = mHelper.getPages();
    String hint = getString(R.string.go_to_hint, page + 1, pages);
    final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, hint);
    builder.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    final AlertDialog dialog = builder.setTitle(R.string.go_to).setPositiveButton(android.R.string.ok, null)
            .show();
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null == mHelper) {
                dialog.dismiss();
                return;
            }

            String text = builder.getText().trim();
            int goTo;
            try {
                goTo = Integer.parseInt(text) - 1;
            } catch (NumberFormatException e) {
                builder.setError(getString(R.string.error_invalid_number));
                return;
            }
            if (goTo < 0 || goTo >= pages) {
                builder.setError(getString(R.string.error_out_of_range));
                return;
            }
            builder.setError(null);
            mHelper.goTo(goTo);
            AppHelper.hideSoftInput(dialog);
            dialog.dismiss();
        }
    });
}

From source file:foam.starwisp.StarwispBuilder.java

public void Build(final StarwispActivity ctx, final String ctxname, JSONArray arr, ViewGroup parent) {

    if (StarwispLinearLayout.m_DisplayMetrics == null) {
        StarwispLinearLayout.m_DisplayMetrics = ctx.getResources().getDisplayMetrics();
    }/*from w  ww.  j  av  a  2 s.c o  m*/

    try {
        String type = arr.getString(0);

        //Log.i("starwisp","building started "+type);

        if (type.equals("build-fragment")) {
            String name = arr.getString(1);
            int ID = arr.getInt(2);
            Fragment fragment = ActivityManager.GetFragment(name);
            LinearLayout inner = new LinearLayout(ctx);
            inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            inner.setId(ID);
            FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction();
            fragmentTransaction.add(ID, fragment);
            fragmentTransaction.commit();
            parent.addView(inner);
            return;
        }

        if (type.equals("map")) {
            int ID = arr.getInt(1);
            LinearLayout inner = new LinearLayout(ctx);
            inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            inner.setId(ID);
            Fragment mapfrag = SupportMapFragment.newInstance();
            FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction();
            fragmentTransaction.add(ID, mapfrag);
            fragmentTransaction.commit();
            parent.addView(inner);
            return;
        }

        if (type.equals("drawmap")) {
            final LinearLayout inner = new LinearLayout(ctx);
            inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            DrawableMap dm = new DrawableMap();
            dm.init(arr.getInt(1), inner, (StarwispActivity) ctx, this, arr.getString(3));
            parent.addView(inner);
            m_DMaps.put(arr.getInt(1), dm);
            return;
        }

        if (type.equals("linear-layout")) {
            StarwispLinearLayout.Build(this, ctx, ctxname, arr, parent);
            return;
        }

        if (type.equals("relative-layout")) {
            StarwispRelativeLayout.Build(this, ctx, ctxname, arr, parent);
            return;
        }

        if (type.equals("draggable")) {
            final LinearLayout v = new LinearLayout(ctx);
            final int id = arr.getInt(1);
            final String behaviour_type = arr.getString(5);
            v.setPadding(20, 20, 20, 10);
            v.setId(id);
            v.setOrientation(StarwispLinearLayout.BuildOrientation(arr.getString(2)));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            v.setClickable(true);
            v.setFocusable(true);

            JSONArray col = arr.getJSONArray(4);
            v.setBackgroundResource(R.drawable.draggable);

            GradientDrawable drawable = (GradientDrawable) v.getBackground();
            final int colour = Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2));
            drawable.setColor(colour);

            /*LayerDrawable bgDrawable = (LayerDrawable)v.getBackground();
            GradientDrawable bgShape = (GradientDrawable)bgDrawable.findDrawableByLayerId(R.id.draggableshape);
            bgShape.setColor(colour);*/
            /*v.getBackground().setColorFilter(colour, PorterDuff.Mode.MULTIPLY);*/

            parent.addView(v);
            JSONArray children = arr.getJSONArray(6);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }

            // Sets a long click listener for the ImageView using an anonymous listener object that
            // implements the OnLongClickListener interface
            if (!behaviour_type.equals("drop-only") && !behaviour_type.equals("drop-only-consume")) {
                v.setOnLongClickListener(new View.OnLongClickListener() {
                    public boolean onLongClick(View vv) {
                        if (id != 99) {
                            ClipData dragData = new ClipData(
                                    new ClipDescription("" + id,
                                            new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN }),
                                    new ClipData.Item("" + id));

                            View.DragShadowBuilder myShadow = new MyDragShadowBuilder(v);
                            Log.i("starwisp", "start drag id " + vv.getId() + " " + v);
                            v.startDrag(dragData, myShadow, v, 0);
                            v.setVisibility(View.GONE);
                            return true;
                        }
                        return false;
                    }
                });
            }

            if (!behaviour_type.equals("drag-only")) {
                // ye gads - needed as drag/drop doesn't deal with nested targets
                final StarwispBuilder that = this;

                v.setOnDragListener(new View.OnDragListener() {
                    public boolean onDrag(View vv, DragEvent event) {

                        //Log.i("starwisp","on drag event happened");

                        final int action = event.getAction();
                        switch (action) {
                        case DragEvent.ACTION_DRAG_STARTED:
                            //Log.i("starwisp","Drag started"+v );
                            if (event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
                                // returns true to indicate that the View can accept the dragged data.
                                return true;
                            } else {
                                // Returns false. During the current drag and drop operation, this View will
                                // not receive events again until ACTION_DRAG_ENDED is sent.
                                return false;
                            }
                        case DragEvent.ACTION_DRAG_ENTERED: {
                            if (that.m_LastDragHighlighted != null) {
                                that.m_LastDragHighlighted.getBackground().setColorFilter(null);
                            }
                            v.getBackground().setColorFilter(0x77777777, PorterDuff.Mode.MULTIPLY);
                            that.m_LastDragHighlighted = v;
                            //Log.i("starwisp","Drag entered"+v );
                            return true;
                        }
                        case DragEvent.ACTION_DRAG_LOCATION: {
                            //View dragee = (View)event.getLocalState();
                            //dragee.setVisibility(View.VISIBLE);
                            //Log.i("starwisp","Drag location"+v );
                            return true;
                        }
                        case DragEvent.ACTION_DRAG_EXITED: {
                            //Log.i("starwisp","Drag exited "+v );
                            v.getBackground().setColorFilter(null);
                            return true;
                        }
                        case DragEvent.ACTION_DROP: {
                            v.getBackground().setColorFilter(null);
                            //Log.i("starwisp","Drag dropped "+v );
                            View otherw = (View) event.getLocalState();
                            //Log.i("starwisp","removing from parent "+((View)otherw.getParent()).getId());

                            // check we are not adding to ourself
                            if (id != otherw.getId()) {
                                ((ViewManager) otherw.getParent()).removeView(otherw);
                                //Log.i("starwisp","adding to " + id);

                                if (!behaviour_type.equals("drop-only-consume")) {
                                    v.addView(otherw);
                                }
                            }
                            otherw.setVisibility(View.VISIBLE);
                            return true;
                        }
                        case DragEvent.ACTION_DRAG_ENDED: {
                            //Log.i("starwisp","Drag ended "+v );
                            v.getBackground().setColorFilter(null);

                            View dragee = (View) event.getLocalState();
                            dragee.setVisibility(View.VISIBLE);

                            if (event.getResult()) {
                                //Log.i("starwisp","sucess " );
                            } else {
                                //Log.i("starwisp","fail " );
                            }
                            ;
                            return true;
                        }
                        // An unknown action type was received.
                        default:
                            //Log.e("starwisp","Unknown action type received by OnDragListener.");
                            break;
                        }
                        ;
                        return true;
                    }
                });
                return;
            }
        }

        if (type.equals("frame-layout")) {
            FrameLayout v = new FrameLayout(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(3);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        /*
        if (type.equals("grid-layout")) {
        GridLayout v = new GridLayout(ctx);
        v.setId(arr.getInt(1));
        v.setRowCount(arr.getInt(2));
        //v.setColumnCount(arr.getInt(2));
        v.setOrientation(BuildOrientation(arr.getString(3)));
        v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
                
        parent.addView(v);
        JSONArray children = arr.getJSONArray(5);
        for (int i=0; i<children.length(); i++) {
            Build(ctx,ctxname,new JSONArray(children.getString(i)), v);
        }
                
        return;
        }
        */

        if (type.equals("scroll-view")) {
            HorizontalScrollView v = new HorizontalScrollView(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(3);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        if (type.equals("scroll-view-vert")) {
            ScrollView v = new ScrollView(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(3);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        if (type.equals("view-pager")) {
            ViewPager v = new ViewPager(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            v.setOffscreenPageLimit(3);
            final JSONArray items = arr.getJSONArray(3);

            v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) {

                @Override
                public int getCount() {
                    return items.length();
                }

                @Override
                public Fragment getItem(int position) {
                    try {
                        String fragname = items.getString(position);
                        return ActivityManager.GetFragment(fragname);
                    } catch (JSONException e) {
                        Log.e("starwisp", "Error parsing fragment data " + e.toString());
                    }
                    return null;
                }
            });
            parent.addView(v);
            return;
        }

        if (type.equals("space")) {
            // Space v = new Space(ctx); (class not found runtime error??)
            TextView v = new TextView(ctx);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
        }

        if (type.equals("image-view")) {
            ImageView v = new ImageView(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            v.setAdjustViewBounds(true);

            String image = arr.getString(2);

            if (image.startsWith("/")) {
                Bitmap b = BitmapCache.Load(image);
                if (b != null) {
                    v.setImageBitmap(b);
                }
            } else {
                int id = ctx.getResources().getIdentifier(image, "drawable", ctx.getPackageName());
                v.setImageResource(id);
            }

            parent.addView(v);
        }

        if (type.equals("image-button")) {
            ImageButton v = new ImageButton(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));

            String image = arr.getString(2);

            if (image.startsWith("/")) {
                v.setImageBitmap(BitmapCache.Load(image));
            } else {
                int id = ctx.getResources().getIdentifier(image, "drawable", ctx.getPackageName());
                v.setImageResource(id);
            }

            final String fn = arr.getString(4);
            v.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Callback(ctx, ctxname, v.getId());
                }
            });

            v.setAdjustViewBounds(true);
            v.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

            parent.addView(v);
        }

        if (type.equals("text-view")) {
            TextView v = new TextView(ctx);
            v.setId(arr.getInt(1));
            v.setText(Html.fromHtml(arr.getString(2)), BufferType.SPANNABLE);
            v.setTextSize(arr.getInt(3));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setLinkTextColor(0xff00aa00);

            // uncomment all this to get hyperlinks to work in text...
            // should make this an option of course

            //v.setClickable(true); // make links
            //v.setMovementMethod(LinkMovementMethod.getInstance());
            //v.setEnabled(true);   // go to browser
            /*v.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View vv, MotionEvent event) {
                return false;
            }
            };*/

            if (arr.length() > 5) {
                if (arr.getString(5).equals("left")) {
                    v.setGravity(Gravity.LEFT);
                } else {
                    if (arr.getString(5).equals("fill")) {
                        v.setGravity(Gravity.FILL);
                    } else {
                        v.setGravity(Gravity.CENTER);
                    }
                }
            } else {
                v.setGravity(Gravity.CENTER);
            }
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            parent.addView(v);
        }

        if (type.equals("debug-text-view")) {
            TextView v = (TextView) ctx.getLayoutInflater().inflate(R.layout.debug_text, null);
            //                v.setBackgroundResource(R.color.black);
            v.setId(arr.getInt(1));
            //                v.setText(Html.fromHtml(arr.getString(2)));
            //                v.setTextColor(R.color.white);
            //                v.setTextSize(arr.getInt(3));
            //                v.setMovementMethod(LinkMovementMethod.getInstance());
            //                v.setMaxLines(10);
            //                v.setVerticalScrollBarEnabled(true);
            //                v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            //v.setMovementMethod(new ScrollingMovementMethod());

            /*
            if (arr.length()>5) {
            if (arr.getString(5).equals("left")) {
                v.setGravity(Gravity.LEFT);
            } else {
                if (arr.getString(5).equals("fill")) {
                    v.setGravity(Gravity.FILL);
                } else {
                    v.setGravity(Gravity.CENTER);
                }
            }
            } else {
            v.setGravity(Gravity.LEFT);
            }
            v.setTypeface(((StarwispActivity)ctx).m_Typeface);*/
            parent.addView(v);
        }

        if (type.equals("web-view")) {
            WebView v = new WebView(ctx);
            v.setId(arr.getInt(1));
            v.setVerticalScrollBarEnabled(false);
            v.loadData(arr.getString(2), "text/html", "utf-8");
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            parent.addView(v);
        }

        if (type.equals("edit-text")) {
            final EditText v = new EditText(ctx);
            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));
            v.setGravity(Gravity.LEFT | Gravity.TOP);

            String inputtype = arr.getString(4);
            if (inputtype.equals("text")) {
                //v.setInputType(InputType.TYPE_CLASS_TEXT);
            } else if (inputtype.equals("numeric")) {
                v.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else if (inputtype.equals("email")) {
                v.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
            }

            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(5)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            final String fn = arr.getString(5);
            //v.setSingleLine(true);

            v.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    CallbackArgs(ctx, ctxname, v.getId(), "\"" + s.toString() + "\"");
                }

                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });

            parent.addView(v);
        }

        if (type.equals("button")) {
            Button v = new Button(ctx);
            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            final String fn = arr.getString(5);
            v.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Callback(ctx, ctxname, v.getId());
                }
            });

            parent.addView(v);
        }

        if (type.equals("colour-button")) {
            Button v = new Button(ctx);
            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            JSONArray col = arr.getJSONArray(6);
            v.getBackground().setColorFilter(
                    Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2)),
                    PorterDuff.Mode.MULTIPLY);
            final String fn = arr.getString(5);
            v.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Callback(ctx, ctxname, v.getId());
                }
            });
            parent.addView(v);
        }

        if (type.equals("toggle-button")) {
            ToggleButton v = new ToggleButton(ctx);
            if (arr.getString(5).equals("fancy")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_fancy, null);
            }

            if (arr.getString(5).equals("yes")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_yes, null);
            }

            if (arr.getString(5).equals("maybe")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_maybe, null);
            }

            if (arr.getString(5).equals("no")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_no, null);
            }

            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            final String fn = arr.getString(6);
            v.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    String arg = "#f";
                    if (((ToggleButton) v).isChecked())
                        arg = "#t";
                    CallbackArgs(ctx, ctxname, v.getId(), arg);
                }
            });
            parent.addView(v);
        }

        if (type.equals("seek-bar")) {
            SeekBar v = new SeekBar(ctx);
            v.setId(arr.getInt(1));
            v.setMax(arr.getInt(2));
            v.setProgress(arr.getInt(2) / 2);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            final String fn = arr.getString(4);

            v.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                public void onProgressChanged(SeekBar v, int a, boolean s) {
                    CallbackArgs(ctx, ctxname, v.getId(), Integer.toString(a));
                }

                public void onStartTrackingTouch(SeekBar v) {
                }

                public void onStopTrackingTouch(SeekBar v) {
                }
            });
            parent.addView(v);
        }

        if (type.equals("spinner")) {
            Spinner v = new Spinner(ctx);
            final int wid = arr.getInt(1);
            v.setId(wid);
            final JSONArray items = arr.getJSONArray(2);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            v.setMinimumWidth(100); // stops tiny buttons
            ArrayList<String> spinnerArray = new ArrayList<String>();

            for (int i = 0; i < items.length(); i++) {
                spinnerArray.add(items.getString(i));
            }

            ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, R.layout.spinner_item,
                    spinnerArray) {
                public View getView(int position, View convertView, ViewGroup parent) {
                    View v = super.getView(position, convertView, parent);
                    ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface);
                    return v;
                }
            };

            spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout);

            v.setAdapter(spinnerArrayAdapter);
            v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> a, View v, int pos, long id) {
                    CallbackArgs(ctx, ctxname, wid, "" + pos);
                }

                public void onNothingSelected(AdapterView<?> v) {
                }
            });

            parent.addView(v);
        }

        if (type.equals("nomadic")) {
            final int wid = arr.getInt(1);
            NomadicSurfaceView v = new NomadicSurfaceView(ctx, wid);
            v.setId(wid);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            Log.e("starwisp", "built the thing");
            parent.addView(v);
            Log.e("starwisp", "addit to the view");
        }

        if (type.equals("canvas")) {
            StarwispCanvas v = new StarwispCanvas(ctx);
            final int wid = arr.getInt(1);
            v.setId(wid);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            v.SetDrawList(arr.getJSONArray(3));
            parent.addView(v);
        }

        if (type.equals("camera-preview")) {
            PictureTaker pt = new PictureTaker();
            CameraPreview v = new CameraPreview(ctx, pt);
            final int wid = arr.getInt(1);
            v.setId(wid);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);

            Log.i("starwisp", "in camera-preview...");

            List<List<String>> info = v.mPictureTaker.GetInfo();
            // can't find a way to do this via a callback yet
            String arg = "'(";
            for (List<String> e : info) {
                arg += "(" + e.get(0) + " " + e.get(1) + ")";
                //Log.i("starwisp","converting prop "+arg);
            }
            arg += ")";
            m_Scheme.eval("(set! camera-properties " + arg + ")");
        }

        if (type.equals("button-grid")) {
            LinearLayout horiz = new LinearLayout(ctx);
            final int id = arr.getInt(1);
            final String buttontype = arr.getString(2);
            horiz.setId(id);
            horiz.setOrientation(LinearLayout.HORIZONTAL);
            parent.addView(horiz);
            int height = arr.getInt(3);
            int textsize = arr.getInt(4);
            LayoutParams lp = BuildLayoutParams(arr.getJSONArray(5));
            JSONArray buttons = arr.getJSONArray(6);
            int count = buttons.length();
            int vertcount = 0;
            LinearLayout vert = null;

            for (int i = 0; i < count; i++) {
                JSONArray button = buttons.getJSONArray(i);

                if (vertcount == 0) {
                    vert = new LinearLayout(ctx);
                    vert.setId(0);
                    vert.setOrientation(LinearLayout.VERTICAL);
                    horiz.addView(vert);
                }
                vertcount = (vertcount + 1) % height;

                if (buttontype.equals("button")) {
                    Button b = new Button(ctx);
                    b.setId(button.getInt(0));
                    b.setText(button.getString(1));
                    b.setTextSize(textsize);
                    b.setLayoutParams(lp);
                    b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                    final String fn = arr.getString(6);
                    b.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t");
                        }
                    });
                    vert.addView(b);
                } else if (buttontype.equals("toggle")) {
                    ToggleButton b = new ToggleButton(ctx);
                    b.setId(button.getInt(0));
                    b.setText(button.getString(1));
                    b.setTextSize(textsize);
                    b.setLayoutParams(lp);
                    b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                    final String fn = arr.getString(6);
                    b.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            String arg = "#f";
                            if (((ToggleButton) v).isChecked())
                                arg = "#t";
                            CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg);
                        }
                    });
                    vert.addView(b);
                }
            }
        }

    } catch (JSONException e) {
        Log.e("starwisp", "Error parsing [" + arr.toString() + "] " + e.toString());
    }

    //Log.i("starwisp","building ended");

}

From source file:com.kmshack.BusanBus.activity.SearchMainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main_common);
    setTitle("");
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerListener(new DrawerListener() {
        public void onDrawerOpened(View drawerView) {
            mDrawerToggle.onDrawerOpened(drawerView);
            getActionBarHelper().onDrawerOpened();
        }/*  w  w  w . j a va2 s .  co  m*/

        public void onDrawerClosed(View drawerView) {
            mDrawerToggle.onDrawerClosed(drawerView);
            getActionBarHelper().onDrawerClosed();
        }

        public void onDrawerSlide(View drawerView, float slideOffset) {
            mDrawerToggle.onDrawerSlide(drawerView, slideOffset);
        }

        public void onDrawerStateChanged(int newState) {
            mDrawerToggle.onDrawerStateChanged(newState);
        }
    });
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    mDrawerToggle = new SherlockActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_dark,
            R.string.drawer_open, R.string.drawer_close);
    mDrawerToggle.syncState();

    mBusDb = BusDb.getInstance(getApplicationContext());
    mUserDb = UserDb.getInstance(getApplicationContext());
    mBusanBusPrefrence = BusanBusPrefrence.getInstance(getApplicationContext());
    mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            switch (msg.what) {

            case TAB_NOSUN:
                searchNosun((String) msg.obj);
                break;

            case TAB_BUSSTOP:
                searchBusStop((String) msg.obj);
                break;
            }

        }
    };

    mImageFavorite = (ImageView) findViewById(R.id.main_tap_favorite_image);
    mImageNosun = (ImageView) findViewById(R.id.main_tap_nosun_image);
    mImageBusstop = (ImageView) findViewById(R.id.main_tap_busstop_image);
    mImageLocation = (ImageView) findViewById(R.id.main_tap_setting_image);

    mFavoriteImageNosun = (TextView) findViewById(R.id.favorite_tab_nosun);
    mFavoriteImageBusstop = (TextView) findViewById(R.id.favorite_tab_busstop);

    mTextFavorite = (TextView) findViewById(R.id.main_tap_favorite_text);
    mTextNosun = (TextView) findViewById(R.id.main_tap_nosun_text);
    mTextBusstop = (TextView) findViewById(R.id.main_tap_busstop_text);
    mTextSetting = (TextView) findViewById(R.id.main_tap_setting_text);

    mNosunListView = (ListView) findViewById(R.id.lv_nosun);
    mBusStopListView = (ListView) findViewById(R.id.lv_busstop);
    mFavoriteListView = (DragSortListView) findViewById(R.id.lv_favorite);

    mNosunListView.setEmptyView((TextView) findViewById(R.id.nosun_empty));
    mBusStopListView.setEmptyView((TextView) findViewById(R.id.busstop_empty));
    mFavoriteListView.setEmptyView((TextView) findViewById(R.id.favorite_empty));

    mFavoriteListView.setDropListener(mOnDrop);
    mFavoriteListView.setRemoveListener(mOnRemove);

    mTextSettingNotice = (TextView) findViewById(R.id.setting_notice);
    mTextSettingUpdate = (TextView) findViewById(R.id.setting_update);

    mLayoutSettingTextSize = (LinearLayout) findViewById(R.id.setting_textsize_sun);
    mLayoutSettingArrive = (LinearLayout) findViewById(R.id.setting_arrive_sun);
    mLayoutSettingFavorite = (LinearLayout) findViewById(R.id.setting_favorite_start);
    mLayoutSettingFavoriteLocation = (LinearLayout) findViewById(R.id.setting_favorite_location);

    mTextViewSettingTextSize = (TextView) findViewById(R.id.setting_textsize_value);
    mCheckSettingArrive = (ImageView) findViewById(R.id.setting_check_arrive_sun);
    mCheckSettingFavorite = (ImageView) findViewById(R.id.setting_check_favorite_start);
    mCheckSettingFavoriteLocation = (ImageView) findViewById(R.id.setting_check_favorite_location);

    mTextSettingNotice.setOnClickListener(mSettingClick);
    mTextSettingUpdate.setOnClickListener(mSettingClick);

    mLayoutSettingTextSize.setOnClickListener(mSettingClick);
    mLayoutSettingArrive.setOnClickListener(mSettingClick);
    mLayoutSettingFavorite.setOnClickListener(mSettingClick);
    mLayoutSettingFavoriteLocation.setOnClickListener(mSettingClick);

    findViewById(R.id.setting_opensource).setOnClickListener(mSettingClick);
    findViewById(R.id.setting_bin).setOnClickListener(mSettingClick);

    if (mBusanBusPrefrence.getIsArriveSort())
        mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_check);
    else
        mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_uncheck);

    if (mBusanBusPrefrence.getIsFavoriteStart())
        mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_check);
    else
        mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_uncheck);

    if (mBusanBusPrefrence.getIsFavoriteLocation())
        mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_check);
    else
        mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_uncheck);

    mNosunSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext())
            .inflate(R.layout.search_bar_nosun, null);
    mNosunSearchView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mNosunEditText = (EditText) mNosunSearchView.findViewById(R.id.et_search_nosun);
    mNosunEditText.setHint(" ");
    mNosunEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
    mNosunEditText.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            mHandler.removeMessages(TAB_NOSUN);
            Message msg = Message.obtain(mHandler, TAB_NOSUN, s.toString());
            mHandler.sendMessageDelayed(msg, 200);
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

    });

    ((LinearLayout) findViewById(R.id.search_nosun)).addView(mNosunSearchView);

    mNosunListView.setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
        }

        public void onScrollStateChanged(AbsListView arg0, int arg1) {
            mInputMethodManager.hideSoftInputFromWindow(mNosunEditText.getWindowToken(), 0);
        }
    });

    mNosunListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Cursor cursor = mMainNosunSearchAdapter.getCursor();
            cursor.moveToPosition(position);

            String nosun = cursor.getString(1);
            String realtime = cursor.getString(cursor.getColumnIndexOrThrow("WEBREALTIME"));
            String up = cursor.getString(2);
            String down = cursor.getString(3);

            Intent intent = new Intent(getApplicationContext(), NosunDetailActivity.class);
            intent.putExtra("NoSun", nosun);
            intent.putExtra("RealTimeNoSun", realtime);
            intent.putExtra("Up", up);
            intent.putExtra("Down", down);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);

        }
    });

    mBusstopSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext())
            .inflate(R.layout.search_bar_busstop, null);
    mBusStopEditText = (EditText) mBusstopSearchView.findViewById(R.id.et_search_busstop);
    mBusStopEditText.setHint("/ ");
    mBusStopEditText.setInputType(InputType.TYPE_CLASS_TEXT);
    mBusStopEditText.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            mHandler.removeMessages(TAB_BUSSTOP);
            Message msg = Message.obtain(mHandler, TAB_BUSSTOP, s.toString());
            mHandler.sendMessageDelayed(msg, 200);
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

    });

    ((LinearLayout) findViewById(R.id.search_busstop)).addView(mBusstopSearchView);

    mBusStopListView.setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
        }

        public void onScrollStateChanged(AbsListView arg0, int arg1) {
            mInputMethodManager.hideSoftInputFromWindow(mBusStopEditText.getWindowToken(), 0);
        }
    });

    mBusStopListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Cursor cursor = mMainStopSearchAdapter.getCursor();
            cursor.moveToPosition(position);

            String busStop = cursor.getString(2).toString();

            Intent intent = new Intent(getApplicationContext(), BusstopDetailActivity.class);
            intent.putExtra("BusStop", busStop);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);

        }
    });

    mFavoriteListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Cursor cursor = null;
            switch (mFavoriteMode) {
            case FAVORITE_TAB_NOSUN:
                cursor = mMainNosunFavoriteAdapter.getCursor();
                break;

            default:
                cursor = mMainStopFavoriteAdapter.getCursor();
                break;
            }

            if (cursor.getCount() > 0) {
                cursor.moveToPosition(position);
                Intent intent = null;

                switch (mFavoriteMode) {
                case FAVORITE_TAB_NOSUN:
                    intent = new Intent(getApplicationContext(), BusArriveActivity.class);
                    intent.putExtra("NOSUN", cursor.getString(1));
                    intent.putExtra("UNIQUEID", cursor.getString(2));
                    intent.putExtra("BUSSTOPNAME", cursor.getString(3));
                    intent.putExtra("UPDOWN", cursor.getString(4));
                    intent.putExtra("ORD", cursor.getString(6));

                    break;

                case FAVORITE_TAB_BUSSTOP:
                    intent = new Intent(getApplicationContext(), BusstopDetailActivity.class);
                    intent.putExtra("BusStop", cursor.getString(2));

                    break;
                }

                if (intent != null) {
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                }
            }
        }
    });

    mTabFavorite = (LinearLayout) findViewById(R.id.main_tap_favorite);
    mTabNosun = (LinearLayout) findViewById(R.id.main_tap_nosun);
    mTabBusstop = (LinearLayout) findViewById(R.id.main_tap_busstop);
    mTabLocation = (LinearLayout) findViewById(R.id.main_tap_location);

    mLayoutFavorite = (LinearLayout) findViewById(R.id.layout_main_favorite);
    mLayoutNosun = (LinearLayout) findViewById(R.id.layout_main_nosun_search);
    mLayoutBusstop = (LinearLayout) findViewById(R.id.layout_main_busstop_search);
    mLayoutLocation = (LinearLayout) findViewById(R.id.layout_main_location);

    mTabFavorite.setOnClickListener(mTabClickListener);
    mTabNosun.setOnClickListener(mTabClickListener);
    mTabBusstop.setOnClickListener(mTabClickListener);
    mTabLocation.setOnClickListener(mTabClickListener);
    mFavoriteImageNosun.setOnClickListener(mTabClickListener);
    mFavoriteImageBusstop.setOnClickListener(mTabClickListener);

    searchNosun("");
    searchBusStop("");

    if (mBusanBusPrefrence.getIsFavoriteStart()) {
        setTabChange(TAB_FAVORITE);
    } else {
        setTabChange(DEFAULT_TAB);
    }

    tracker.trackPageView("/SearchMain");

    loadSettingTextSizeSelect();
}

From source file:org.secu3.android.ParamActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    adapter = (ParamItemsAdapter) parent.getAdapter();
    if (adapter != null) {
        this.position = position;
        BaseParamItem i = (BaseParamItem) adapter.getItem(position);
        if (i instanceof ParamItemInteger) {
            dialog = new CustomNumberPickerIntegerDialog();
            dialog.setValid(isValid);//  ww w . j  a va 2  s  .co  m
            ((CustomNumberPickerIntegerDialog) dialog.setId(i.getNameId()))
                    .setRange(((ParamItemInteger) i).getValue(), ((ParamItemInteger) i).getMinValue(),
                            ((ParamItemInteger) i).getMaxValue(), ((ParamItemInteger) i).getStepValue())
                    .setOnCustomNumberPickerAcceptListener(this).show(getSupportFragmentManager(), i.getName());
        } else if (i instanceof ParamItemFloat) {
            dialog = new CustomNumberPickerFloatDialog();
            dialog.setValid(isValid);
            ((CustomNumberPickerFloatDialog) dialog.setId(i.getNameId()))
                    .setRange(((ParamItemFloat) i).getValue(), ((ParamItemFloat) i).getMinValue(),
                            ((ParamItemFloat) i).getMaxValue(), ((ParamItemFloat) i).getStepValue())
                    .setFormat(((ParamItemFloat) i).getFormat()).setOnCustomNumberPickerAcceptListener(this)
                    .show(getSupportFragmentManager(), i.getName());
        } else if (i instanceof ParamItemBoolean) {
            adapter.setValue(String.valueOf(!((ParamItemBoolean) i).getValue()), position);
            onItemChange(i.getNameId());
        } else if (i instanceof ParamItemString) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(i.getName());
            final EditText input = new EditText(this);
            bluetoothSecurityFlags = i.getNameId();
            input.setText(((ParamItemString) i).getValue());
            switch (bluetoothSecurityFlags) {
            case R.string.secur_par_bluetooth_name_title:
                input.setInputType(InputType.TYPE_CLASS_TEXT);
                break;
            case R.string.secur_par_bluetooth_pass_title:
                input.setInputType(InputType.TYPE_CLASS_NUMBER);
                break;
            }
            builder.setView(input);
            builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    bluetoothSecurityValue = input.getText().toString();
                    onItemChange(bluetoothSecurityFlags);
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
        }
    }
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCvvPrompt(final PaymentOption paymentOption) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter CVV.";
    String positiveButtonText = "OK";
    alert.setTitle("CVV");
    alert.setMessage(message);/*w w  w.j  a  va2 s.co m*/
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(4);
    input.setFilters(FilterArray);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String cvv = input.getText().toString();
            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
            otherPaymentOption = paymentOption;
            ((CardOption) otherPaymentOption).setCardCVV(cvv);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    input.requestFocus();
    alert.show();
}

From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java

/**
 * Dynamically creates an edit text/*from  ww  w .jav  a 2s .  c o m*/
 *
 * @param open311Attribute contains the open311 attributes
 */
private void createEditText(Open311Attribute open311Attribute) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_text_item, null, false);

    ImageView icon = ((ImageView) layout.findViewById(R.id.ri_ic_question_answer));
    icon.setColorFilter(getResources().getColor(R.color.material_gray));

    Spannable desc = new SpannableString(MyTextUtils.toSentenceCase(open311Attribute.getDescription()));
    EditText editText = ((EditText) layout.findViewById(R.id.riti_editText));
    if (open311Attribute.getRequired()) {
        Spannable req = new SpannableString("(required)");
        req.setSpan(new ForegroundColorSpan(Color.RED), 0, req.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        editText.setHint(TextUtils.concat(desc, " ", req));
    } else {
        editText.setHint(desc);
    }

    if (Open311DataType.NUMBER.equals(open311Attribute.getDatatype())) {
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    } else if (Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) {
        editText.setInputType(InputType.TYPE_CLASS_DATETIME);
    }

    // Restore view state from attribute result hash map
    AttributeValue av = mAttributeValueHashMap.get(open311Attribute.getCode());
    if (av != null) {
        editText.setText(av.getSingleValue());
    }

    // Dynamically fill stop id if this is a transit service
    // And if this is a bus stop field
    if (ServiceUtils.isTransitServiceByType(mService.getType())
            && ServiceUtils.isStopIdField(open311Attribute.getDescription())) {

        icon.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ri_flag_triangle));

        ObaStop obaStop = getIssueLocationHelper().getObaStop();
        if (obaStop != null) {
            editText.setText(obaStop.getStopCode());
        }
    }

    mInfoLayout.addView(layout);
    mDynamicAttributeUIMap.put(open311Attribute.getCode(), editText);
}

From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java

public static void createViewRunnables() {
    viewRunnables = new HashMap<>(30);
    viewRunnables.put("scaleType", new ViewParamRunnable() {
        @Override/*from w w  w  .j  a v  a 2s.c  o  m*/
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof ImageView) {
                ImageView.ScaleType scaleType = ((ImageView) view).getScaleType();
                switch (value.toLowerCase()) {
                case "center":
                    scaleType = ImageView.ScaleType.CENTER;
                    break;
                case "center_crop":
                    scaleType = ImageView.ScaleType.CENTER_CROP;
                    break;
                case "center_inside":
                    scaleType = ImageView.ScaleType.CENTER_INSIDE;
                    break;
                case "fit_center":
                    scaleType = ImageView.ScaleType.FIT_CENTER;
                    break;
                case "fit_end":
                    scaleType = ImageView.ScaleType.FIT_END;
                    break;
                case "fit_start":
                    scaleType = ImageView.ScaleType.FIT_START;
                    break;
                case "fit_xy":
                    scaleType = ImageView.ScaleType.FIT_XY;
                    break;
                case "matrix":
                    scaleType = ImageView.ScaleType.MATRIX;
                    break;
                }
                ((ImageView) view).setScaleType(scaleType);
            }
        }
    });
    viewRunnables.put("orientation", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof LinearLayout) {
                ((LinearLayout) view).setOrientation(
                        value.equals("vertical") ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
            }
        }
    });
    viewRunnables.put("text", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setText(value);
            }
        }
    });
    viewRunnables.put("textSize", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
                        DimensionConverter.stringToDimension(value, view.getResources().getDisplayMetrics()));
            }
        }
    });
    viewRunnables.put("textColor", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setTextColor(parseColor(view, value));
            }
        }
    });
    viewRunnables.put("textStyle", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                int typeFace = Typeface.NORMAL;
                if (value.contains("bold"))
                    typeFace |= Typeface.BOLD;
                else if (value.contains("italic"))
                    typeFace |= Typeface.ITALIC;
                ((TextView) view).setTypeface(null, typeFace);
            }
        }
    });
    viewRunnables.put("textAlignment", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
                int alignment = View.TEXT_ALIGNMENT_TEXT_START;
                switch (value) {
                case "center":
                    alignment = View.TEXT_ALIGNMENT_CENTER;
                    break;
                case "left":
                case "textStart":
                    break;
                case "right":
                case "textEnd":
                    alignment = View.TEXT_ALIGNMENT_TEXT_END;
                    break;
                }
                view.setTextAlignment(alignment);
            } else {
                int gravity = Gravity.LEFT;
                switch (value) {
                case "center":
                    gravity = Gravity.CENTER;
                    break;
                case "left":
                case "textStart":
                    break;
                case "right":
                case "textEnd":
                    gravity = Gravity.RIGHT;
                    break;
                }
                ((TextView) view).setGravity(gravity);
            }
        }
    });
    viewRunnables.put("ellipsize", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                TextUtils.TruncateAt where = TextUtils.TruncateAt.END;
                switch (value) {
                case "start":
                    where = TextUtils.TruncateAt.START;
                    break;
                case "middle":
                    where = TextUtils.TruncateAt.MIDDLE;
                    break;
                case "marquee":
                    where = TextUtils.TruncateAt.MARQUEE;
                    break;
                case "end":
                    break;
                }
                ((TextView) view).setEllipsize(where);
            }
        }
    });
    viewRunnables.put("singleLine", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setSingleLine();
            }
        }
    });
    viewRunnables.put("hint", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof EditText) {
                ((EditText) view).setHint(value);
            }
        }
    });
    viewRunnables.put("inputType", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                int inputType = 0;
                switch (value) {
                case "textEmailAddress":
                    inputType |= InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
                    break;
                case "number":
                    inputType |= InputType.TYPE_CLASS_NUMBER;
                    break;
                case "phone":
                    inputType |= InputType.TYPE_CLASS_PHONE;
                    break;
                }
                if (inputType > 0)
                    ((TextView) view).setInputType(inputType);
            }
        }
    });
    viewRunnables.put("gravity", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            int gravity = parseGravity(value);
            if (view instanceof TextView) {
                ((TextView) view).setGravity(gravity);
            } else if (view instanceof LinearLayout) {
                ((LinearLayout) view).setGravity(gravity);
            } else if (view instanceof RelativeLayout) {
                ((RelativeLayout) view).setGravity(gravity);
            }
        }
    });
    viewRunnables.put("src", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof ImageView) {
                String imageName = value;
                if (imageName.startsWith("//"))
                    imageName = "http:" + imageName;
                if (imageName.startsWith("http")) {
                    if (imageLoader != null) {
                        if (attrs.containsKey("cornerRadius")) {
                            int radius = DimensionConverter.stringToDimensionPixelSize(
                                    attrs.get("cornerRadius"), view.getResources().getDisplayMetrics());
                            imageLoader.loadRoundedImage((ImageView) view, imageName, radius);
                        } else {
                            imageLoader.loadImage((ImageView) view, imageName);
                        }
                    }
                } else if (imageName.startsWith("@drawable/")) {
                    imageName = imageName.substring("@drawable/".length());
                    ((ImageView) view).setImageDrawable(getDrawableByName(view, imageName));
                }
            }
        }
    });
    viewRunnables.put("visibility", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            int visibility = View.VISIBLE;
            String visValue = value.toLowerCase();
            if (visValue.equals("gone"))
                visibility = View.GONE;
            else if (visValue.equals("invisible"))
                visibility = View.INVISIBLE;
            view.setVisibility(visibility);
        }
    });
    viewRunnables.put("clickable", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            view.setClickable(value.equals("true"));
        }
    });
    viewRunnables.put("tag", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            // Sigh, this is dangerous because we use tags for other purposes
            if (view.getTag() == null)
                view.setTag(value);
        }
    });
    viewRunnables.put("onClick", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            view.setOnClickListener(getClickListener(parent, value));
        }
    });
}

From source file:com.citrus.sample.WalletPaymentFragment.java

void showTokenizedPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    final String message = "Auto Load Money with Saved Card";
    String positiveButtonText = "Auto Load";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelamt = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAmount = new TextView(getActivity());
    final EditText editLoadAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editThresholdAmount = new EditText(getActivity());
    final Button btnSelectSavedCards = new Button(getActivity());
    btnSelectSavedCards.setText("Select Saved Card");

    editLoadAmount.setSingleLine(true);//from  www.j a  va 2 s  . co m
    editThresholdAmount.setSingleLine(true);

    editAmount.setSingleLine(true);
    labelamt.setText("Load Amount");
    labelAmount.setText("Auto Load Amount");
    labelMobileNo.setText("Threshold Amount");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelamt.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    editLoadAmount.setLayoutParams(layoutParams);
    editThresholdAmount.setLayoutParams(layoutParams);
    btnSelectSavedCards.setLayoutParams(layoutParams);

    btnSelectSavedCards.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCitrusClient.getWallet(new Callback<List<PaymentOption>>() {
                @Override
                public void success(List<PaymentOption> paymentOptions) {
                    walletList.clear();
                    for (PaymentOption paymentOption : paymentOptions) {
                        if (paymentOption instanceof CreditCardOption) {
                            if (Arrays.asList(AUTO_LOAD_CARD_SCHEMS)
                                    .contains(((CardOption) paymentOption).getCardScheme().toString()))
                                walletList.add(paymentOption); //only available for Master and Visa Credit Card....
                        }
                    }
                    savedOptionsAdapter = new SavedOptionsAdapter(getActivity(), walletList);
                    showSavedAccountsDialog();
                }

                @Override
                public void error(CitrusError error) {
                    Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                }
            });
        }
    });

    linearLayout.addView(labelamt);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAmount);
    linearLayout.addView(editLoadAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editThresholdAmount);
    linearLayout.addView(btnSelectSavedCards);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Auto Load Money with Saved Card");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            final String amount = editAmount.getText().toString();
            final String loadAmount = editLoadAmount.getText().toString();
            final String thresHoldAmount = editThresholdAmount.getText().toString();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);

            if (TextUtils.isEmpty(amount)) {
                Toast.makeText(getActivity(), "Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(loadAmount)) {
                Toast.makeText(getActivity(), "Load Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(thresHoldAmount)) {
                Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(thresHoldAmount) < new Double("500")) {
                Toast.makeText(getActivity(), "thresHoldAmount  should not be less than 500",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) {
                Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (otherPaymentOption == null) {
                Toast.makeText(getActivity(), "Saved Card Option is null.", Toast.LENGTH_SHORT).show();
            }

            try {
                PaymentType paymentType = new PaymentType.LoadMoney(new Amount(amount), otherPaymentOption);
                mCitrusClient.autoLoadMoney((PaymentType.LoadMoney) paymentType, new Amount(thresHoldAmount),
                        new Amount(loadAmount), new Callback<SubscriptionResponse>() {
                            @Override
                            public void success(SubscriptionResponse subscriptionResponse) {
                                Logger.d("AUTO LOAD RESPONSE ***"
                                        + subscriptionResponse.getSubscriptionResponseMessage());
                                Toast.makeText(getActivity(),
                                        subscriptionResponse.getSubscriptionResponseMessage(),
                                        Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void error(CitrusError error) {
                                Logger.d("AUTO LOAD ERROR ***" + error.getMessage());
                                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                            }
                        });
            } catch (CitrusException e) {
                e.printStackTrace();
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editLoadAmount.requestFocus();
    alert.show();
}