public ViewHolder(View itemView) {
      super(itemView);
      choice = (CheckBox) itemView.findViewById(R.id.choiceButton);

      // selecting choices(if radio type)
      /*choice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if(isChoiceRadioType) {
                  //Act as Radio Button
                  mSelectedItem = getAdapterPosition();
                  notifyDataSetChanged();
              }else{
                  //Act as CheckBox(Nothing Required)
              }
          }
      });*/
      choice.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (isChoiceRadioType) {
                // Act as Radio Button
                mSelectedItem = getAdapterPosition();
                notifyDataSetChanged();
              } else {
                // Act as CheckBox(Nothing Required)
              }
            }
          });

      // removing choices on long press
      choice.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              // Remove element from Arraylist
              updateAdapterView.itemRemoved(getAdapterPosition());
              return false;
            }
          });
    }
示例#2
0
  // set all UI elements
  private void setButtons() {

    starCheckBox = (CheckBox) findViewById(R.id.favourite_star_checkbox_word_showcase);
    starCheckBox.setOnClickListener(this);
    starCheckBox.setOnLongClickListener(this);

    // Instantiate buttons
    Button stopButton = (Button) findViewById(R.id.word_showcase_stop_button);
    Button playButton = (Button) findViewById(R.id.word_showcase_play_button);
    Button defButton = (Button) findViewById(R.id.word_showcase_play_description_button);

    // Button OnClickListeners
    stopButton.setOnClickListener(this);
    playButton.setOnClickListener(this);
    defButton.setOnClickListener(this);

    stopButton.setOnLongClickListener(this);
    playButton.setOnLongClickListener(this);
    defButton.setOnLongClickListener(this);
  }
 @Override
 public void setOnLongClickListener(OnLongClickListener l) {
     for (CheckBox c : mCheckboxes) {
         c.setOnLongClickListener(l);
     }
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {

    mDataProvider = RealFarmProvider.getInstance(context);

    super.onCreate(savedInstanceState, R.layout.sowing_dialog);
    setHelpIcon(findViewById(R.id.helpIndicator));

    System.out.println("plant done");
    final TextView day_sow = (TextView) findViewById(R.id.dlg_lbl_day_sow);
    // final TextView month_sow = (TextView)
    // findViewById(R.id.dlg_lbl_month_sow);

    playAudio(R.raw.thankyouclickingactionsowing);

    // tracks the application usage.
    ApplicationTracker.getInstance().logEvent(EventType.PAGE_VIEW, LOG_TAG);

    final ImageView bg_units_no_sow = (ImageView) findViewById(R.id.img_bg_units_no_sow);
    final ImageView bg_units_sow = (ImageView) findViewById(R.id.img_bg_units_sow);
    final ImageView bg_treatment_sow = (ImageView) findViewById(R.id.img_bg_treatment_sow);
    final ImageView bg_day_sow = (ImageView) findViewById(R.id.img_bg_day_sow);
    final ImageView bg_month_sow = (ImageView) findViewById(R.id.img_bg_month_sow);

    final View item1;
    final View item2;
    final View item3;
    final View item4;
    final View item5;
    View home;
    View help;
    item1 = findViewById(R.id.home_btn_var_sow);
    item2 = findViewById(R.id.home_btn_units_sow);
    item3 = findViewById(R.id.home_btn_day_sow);
    item4 = findViewById(R.id.home_btn_treat_sow);
    item5 = findViewById(R.id.home_btn_units_no_sow);

    final Button item6 = (Button) findViewById(R.id.home_btn_month_sow);
    home = findViewById(R.id.aggr_img_home);
    help = findViewById(R.id.aggr_img_help);

    item1.setOnLongClickListener(this);
    item2.setOnLongClickListener(this);
    item3.setOnLongClickListener(this);
    item4.setOnLongClickListener(this);
    item5.setOnLongClickListener(this);
    item6.setOnLongClickListener(this);
    help.setOnLongClickListener(this);

    final Button variety;
    final Button Amount;
    final Button Date;
    final Button Treatment;
    final Button Intercrop;

    variety = (Button) findViewById(R.id.variety_sow_txt_btn);
    Amount = (Button) findViewById(R.id.amount_sow_txt_btn);
    Date = (Button) findViewById(R.id.date_sow_txt_btn);
    Treatment = (Button) findViewById(R.id.treat_sow_txt_btn);
    Intercrop = (Button) findViewById(R.id.intercrop_sow_txt_btn);

    variety.setOnLongClickListener(this);
    Amount.setOnLongClickListener(this);
    Date.setOnLongClickListener(this);
    Treatment.setOnLongClickListener(this);
    Intercrop.setOnLongClickListener(this);

    item1.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            stopaudio();
            Log.d("in variety sowing dialog", "in dialog");
            final Dialog dlg = new Dialog(v.getContext());
            dlg.setContentView(R.layout.dialog_variety);
            dlg.setCancelable(true);
            dlg.setTitle("Choose the Variety of seed sowed");
            Log.d("in variety sowing dialog", "in dialog");
            dlg.show();

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "variety");

            final View variety1;
            final View variety2;
            final View variety3;
            final View variety4;
            final View variety5;
            final View variety6;

            final ImageView img_1 = (ImageView) findViewById(R.id.dlg_var_sow);
            final TextView var_text = (TextView) findViewById(R.id.dlg_var_text_sow);

            // gets the available varieties
            variety1 = dlg.findViewById(R.id.button_variety_1);
            variety2 = dlg.findViewById(R.id.button_variety_2);
            variety3 = dlg.findViewById(R.id.button_variety_3);
            variety4 = dlg.findViewById(R.id.button_variety_4);
            variety5 = dlg.findViewById(R.id.button_variety_5);
            variety6 = dlg.findViewById(R.id.button_variety_6);

            // sets the long click listener for help support
            variety1.setOnLongClickListener(parentReference);
            variety2.setOnLongClickListener(parentReference);
            variety3.setOnLongClickListener(parentReference);
            variety4.setOnLongClickListener(parentReference);
            variety5.setOnLongClickListener(parentReference);
            variety6.setOnLongClickListener(parentReference);

            variety1.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 1 picked ", "in dialog");
                    // img_1.setMaxWidth(300);
                    img_1.setImageResource(R.drawable.pic_90px_bajra_tiled);
                    var_text.setText("Bajra");
                    seed_sow = 1;

                    TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "variety", seed_sow);

                    dlg.cancel();
                  }
                });

            variety2.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 2 picked ", "in dialog");
                    img_1.setImageResource(R.drawable.pic_90px_castor_tiled);
                    var_text.setText("Castor");
                    seed_sow = 2;

                    TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "variety", seed_sow);

                    dlg.cancel();
                  }
                });

            variety3.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 3 picked ", "in dialog");
                    img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("Cowpea");
                    seed_sow = 3;

                    TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "variety", seed_sow);

                    dlg.cancel();
                  }
                });

            variety4.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 3 picked ", "in dialog");
                    img_1.setImageResource(R.drawable.pic_90px_greengram_tiled);
                    var_text.setText("Greengram");
                    seed_sow = 4;

                    TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "variety", seed_sow);

                    dlg.cancel();
                  }
                });
            variety5.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 3 picked ", "in dialog");
                    img_1.setImageResource(R.drawable.pic_90px_groundnut_tiled);
                    var_text.setText("Groundnut");
                    seed_sow = 5;

                    TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "variety", seed_sow);

                    dlg.cancel();
                  }
                });
            variety6.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 3 picked ", "in dialog");
                    img_1.setImageResource(R.drawable.pic_90px_horsegram_tiled);
                    var_text.setText("Horsegram");
                    seed_sow = 6;
                    TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "variety", seed_sow);
                    dlg.cancel();
                  }
                });
          }
        });

    item2.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            stopaudio();
            Log.d("in units sow dialog", "in dialog");
            final Dialog dlg = new Dialog(v.getContext());
            dlg.setContentView(R.layout.units_dialog);
            dlg.setCancelable(true);
            dlg.setTitle("Choose the units");
            Log.d("in units sow dialog", "in dialog");
            dlg.show();

            final Button unit1;
            final Button unit2;
            final Button unit3;

            final TextView var_text = (TextView) findViewById(R.id.dlg_lbl_unit_sow);
            unit1 = (Button) dlg.findViewById(R.id.home_btn_units_1);
            unit2 = (Button) dlg.findViewById(R.id.home_btn_units_2);
            unit3 = (Button) dlg.findViewById(R.id.home_btn_units_3);

            dlg.findViewById(R.id.home_btn_units_1).setOnLongClickListener(parentReference);
            dlg.findViewById(R.id.home_btn_units_2).setOnLongClickListener(parentReference);
            dlg.findViewById(R.id.home_btn_units_3).setOnLongClickListener(parentReference);

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "units");

            unit1.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 1 picked ", "in dialog");
                    // img_1.setMaxWidth(300);
                    // img_1.setImageResource(R.drawable.pic_90px_bajra_tiled);
                    var_text.setText("10 Kgs");
                    units_sow = "Bag of 10 Kgs";

                    TableRow tr_feedback = (TableRow) findViewById(R.id.units_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_units_sow.setImageResource(R.drawable.empty_not);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "units", units_sow);

                    dlg.cancel();
                  }
                });

            unit2.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 2 picked ", "in dialog");
                    // img_1.setImageResource(R.drawable.pic_90px_castor_tiled);
                    var_text.setText("20 Kgs");
                    units_sow = "Bag of 20 Kgs";

                    TableRow tr_feedback = (TableRow) findViewById(R.id.units_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_units_sow.setImageResource(R.drawable.empty_not);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "units", units_sow);

                    dlg.cancel();
                  }
                });

            unit3.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 3 picked ", "in dialog");
                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("50 Kgs");
                    units_sow = "Bag of 50 Kgs";

                    TableRow tr_feedback = (TableRow) findViewById(R.id.units_sow_tr);
                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_units_sow.setImageResource(R.drawable.empty_not);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "units", units_sow);

                    dlg.cancel();
                  }
                });
          }
        });

    item3.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            stopaudio();
            Log.d("in variety sowing dialog", "in dialog");
            final Dialog dlg = new Dialog(v.getContext());
            dlg.setContentView(R.layout.numberentry_dialog);
            dlg.setCancelable(true);
            dlg.setTitle("Choose the Date");
            Log.d("in variety sowing dialog", "in dialog");
            dlg.show();

            playAudio(R.raw.dateinfo); // 20-06-2012

            Button no_ok = (Button) dlg.findViewById(R.id.number_ok);
            Button no_cancel = (Button) dlg.findViewById(R.id.number_cancel);

            ((Button) dlg.findViewById(R.id.number_ok)) // 20-06-2012
                .setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.number_cancel)).setOnLongClickListener(parentReference);

            no_ok.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    NumberPicker mynpd = (NumberPicker) dlg.findViewById(R.id.numberpick);
                    day_sow_int = mynpd.getValue();
                    day_sow_str = String.valueOf(day_sow_int);
                    day_sow.setText(day_sow_str);
                    if (day_sow_int != 0) {

                      TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);
                      tr_feedback.setBackgroundResource(R.drawable.def_img);
                      bg_day_sow.setImageResource(R.drawable.empty_not);
                    }

                    dlg.cancel();
                  }
                });
            no_cancel.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    dlg.cancel();

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "units", "cancel");
                  }
                });
          }
        });

    item4.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            stopaudio();
            Log.d("in treat sow dialog", "in dialog");
            final Dialog dlg = new Dialog(v.getContext());
            dlg.setContentView(R.layout.treat_sow_dialog);
            dlg.setCancelable(true);
            dlg.setTitle("Select weather you have treated the seeds");
            Log.d("in treat sow dialog", "in dialog");
            dlg.show();

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "treatment");

            final Button treat1;
            final Button treat2;

            final TextView var_text = (TextView) findViewById(R.id.dlg_lbl_treat_sow);
            treat1 = (Button) dlg.findViewById(R.id.home_treat_sow_1);
            treat2 = (Button) dlg.findViewById(R.id.home_treat_sow_2);

            dlg.findViewById(R.id.home_treat_sow_1).setOnLongClickListener(parentReference);
            dlg.findViewById(R.id.home_treat_sow_2).setOnLongClickListener(parentReference);

            treat1.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 1 picked ", "in dialog");

                    var_text.setText("Treated");
                    treatment_sow = "treated";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.treatment_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_treatment_sow.setImageResource(R.drawable.empty_not);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "treatment", treatment_sow);

                    dlg.cancel();
                  }
                });

            treat2.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    Log.d("var 2 picked ", "in dialog");

                    var_text.setText("May not Treat");
                    treatment_sow = "may not treat";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.treatment_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_treatment_sow.setImageResource(R.drawable.empty_not);

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "treatment", treatment_sow);

                    dlg.cancel();
                  }
                });
          }
        });

    final TextView no_text = (TextView) findViewById(R.id.dlg_lbl_unit_no_sow);

    item5.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            stopaudio();
            Log.d("in variety sowing dialog", "in dialog");
            final Dialog dlg = new Dialog(v.getContext());
            dlg.setContentView(R.layout.numberentry_dialog);
            dlg.setCancelable(true);
            dlg.setTitle("Choose the Number of bags");
            Log.d("in variety sowing dialog", "in dialog");
            dlg.show();

            playAudio(R.raw.noofbags);

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "bags");

            Button no_ok = (Button) dlg.findViewById(R.id.number_ok);
            Button no_cancel = (Button) dlg.findViewById(R.id.number_cancel);

            dlg.findViewById(R.id.number_ok).setOnLongClickListener(parentReference);
            dlg.findViewById(R.id.number_cancel).setOnLongClickListener(parentReference);

            no_ok.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    NumberPicker mynp1 = (NumberPicker) dlg.findViewById(R.id.numberpick);
                    sow_no = mynp1.getValue();
                    sow_no_sel = String.valueOf(sow_no);
                    no_text.setText(sow_no_sel);
                    if (sow_no != 0) {

                      TableRow tr_feedback = (TableRow) findViewById(R.id.units_sow_tr);

                      tr_feedback.setBackgroundResource(R.drawable.def_img);
                      bg_units_no_sow.setImageResource(R.drawable.empty_not);

                      // tracks the application usage.
                      ApplicationTracker.getInstance()
                          .logEvent(EventType.CLICK, LOG_TAG, "bags", sow_no_sel);
                    }

                    dlg.cancel();
                  }
                });
            no_cancel.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {
                    dlg.cancel();

                    // tracks the application usage.
                    ApplicationTracker.getInstance()
                        .logEvent(EventType.CLICK, LOG_TAG, "bags", "cancel");
                  }
                });
          }
        });

    item6.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            stopaudio();
            Log.d("in variety sowing dialog", "in dialog");
            final Dialog dlg = new Dialog(v.getContext());
            dlg.setContentView(R.layout.months_dialog);
            dlg.setCancelable(true);
            dlg.setTitle("Choose the month ");
            Log.d("in variety sowing dialog", "in dialog");
            dlg.show();

            final Button month1 = (Button) dlg.findViewById(R.id.home_month_1);
            final Button month2 = (Button) dlg.findViewById(R.id.home_month_2);
            final Button month3 = (Button) dlg.findViewById(R.id.home_month_3);
            final Button month4 = (Button) dlg.findViewById(R.id.home_month_4);
            final Button month5 = (Button) dlg.findViewById(R.id.home_month_5);
            final Button month6 = (Button) dlg.findViewById(R.id.home_month_6);
            final Button month7 = (Button) dlg.findViewById(R.id.home_month_7);
            final Button month8 = (Button) dlg.findViewById(R.id.home_month_8);
            final Button month9 = (Button) dlg.findViewById(R.id.home_month_9);
            final Button month10 = (Button) dlg.findViewById(R.id.home_month_10);
            final Button month11 = (Button) dlg.findViewById(R.id.home_month_11);
            final Button month12 = (Button) dlg.findViewById(R.id.home_month_12);

            ((Button) dlg.findViewById(R.id.home_month_1))
                .setOnLongClickListener(parentReference); // audio
            // integration
            ((Button) dlg.findViewById(R.id.home_month_2)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_3)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_4)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_5)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_6)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_7))
                .setOnLongClickListener(parentReference); // audio
            // integration
            ((Button) dlg.findViewById(R.id.home_month_8)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_9)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_10)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_11)).setOnLongClickListener(parentReference);
            ((Button) dlg.findViewById(R.id.home_month_12)).setOnLongClickListener(parentReference);

            final TextView var_text = (TextView) findViewById(R.id.dlg_lbl_month_sow);

            month1.setOnClickListener(
                new View.OnClickListener() {

                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("01");
                    months_sow = "01";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month2.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("02");
                    months_sow = "02";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month3.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("03");
                    months_sow = "03";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month4.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("04");
                    months_sow = "04";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month5.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("05");
                    months_sow = "05";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month6.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("06");
                    months_sow = "06";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month7.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("07");
                    months_sow = "07";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month8.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("08");
                    months_sow = "08";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month9.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("09");
                    months_sow = "09";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month10.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("10");
                    months_sow = "10";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month11.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("11");
                    months_sow = "11";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);

                    dlg.cancel();
                  }
                });

            month12.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View v) {

                    // img_1.setImageResource(R.drawable.pic_90px_cowpea_tiled);
                    var_text.setText("12");
                    months_sow = "12";
                    TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

                    tr_feedback.setBackgroundResource(R.drawable.def_img);
                    bg_month_sow.setImageResource(R.drawable.empty_not);
                    dlg.cancel();
                  }
                });
          }
        });

    final CheckBox intercrop = (CheckBox) findViewById(R.id.chkintercrop);

    intercrop.setOnLongClickListener(this); // audio integration

    intercrop.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // is chkIos checked?
            if (((CheckBox) v).isChecked()) {

              // tracks the application usage.
              ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "intercrop");
            }
          }
        });

    Button btnNext = (Button) findViewById(R.id.sow_ok);
    Button cancel = (Button) findViewById(R.id.sow_cancel);

    btnNext.setOnLongClickListener(this); // Integration
    cancel.setOnLongClickListener(this);

    cancel.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            cancelaudio();

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "cancel");
          }
        });

    btnNext.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "ok");

            // Toast.makeText(action_sowing.this, "User enetred " +
            // sow_no_sel + "kgs", Toast.LENGTH_LONG).show();
            int flag1, flag2, flag3, flag4;
            if (seed_sow == 0) {
              flag1 = 1;

              TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
              tr_feedback.setBackgroundResource(R.drawable.def_img_not);

              // tracks the application usage.
              ApplicationTracker.getInstance().logEvent(EventType.ERROR, LOG_TAG, "variety");

            } else {
              flag1 = 0;

              TableRow tr_feedback = (TableRow) findViewById(R.id.seed_type_sow_tr);
              tr_feedback.setBackgroundResource(R.drawable.def_img);
            }

            if (units_sow.toString().equalsIgnoreCase("0") || sow_no == 0) {

              flag2 = 1;

              TableRow tr_feedback = (TableRow) findViewById(R.id.units_sow_tr);
              tr_feedback.setBackgroundResource(R.drawable.def_img_not);

              // tracks the application usage.
              ApplicationTracker.getInstance().logEvent(EventType.ERROR, LOG_TAG, "units");

            } else {

              flag2 = 0;

              TableRow tr_feedback = (TableRow) findViewById(R.id.units_sow_tr);

              tr_feedback.setBackgroundResource(R.drawable.def_img);
            }

            if (treatment_sow.toString().equalsIgnoreCase("0")) {

              flag3 = 1;

              TableRow tr_feedback = (TableRow) findViewById(R.id.treatment_sow_tr);
              tr_feedback.setBackgroundResource(R.drawable.def_img_not);

              // tracks the application usage.
              ApplicationTracker.getInstance().logEvent(EventType.ERROR, LOG_TAG, "treatment");

            } else {

              flag3 = 0;

              TableRow tr_feedback = (TableRow) findViewById(R.id.treatment_sow_tr);

              tr_feedback.setBackgroundResource(R.drawable.def_img);
            }

            if (months_sow.toString().equalsIgnoreCase("0") || day_sow_int == 0) {

              flag4 = 1;

              TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

              tr_feedback.setBackgroundResource(R.drawable.def_img_not);

              // tracks the application usage.
              ApplicationTracker.getInstance().logEvent(EventType.ERROR, LOG_TAG, "day");

            } else {

              flag4 = 0;

              days_sel_sow = day_sow_int + "." + months_sow;
              TableRow tr_feedback = (TableRow) findViewById(R.id.day_sow_tr);

              tr_feedback.setBackgroundResource(R.drawable.def_img);
            }

            if (flag1 == 0 && flag2 == 0 && flag3 == 0 && flag4 == 0) {
              System.out.println("sowing writing");
              mDataProvider.setSowing(
                  Global.plotId, sow_no, seed_sow, units_sow, days_sel_sow, treatment_sow, 0, 0);

              Intent adminintent = new Intent(action_sowing.this, Homescreen.class);
              startActivity(adminintent);
              action_sowing.this.finish();
              okaudio();

            } else initmissingval();
          }
        });

    home.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent adminintent = new Intent(action_sowing.this, Homescreen.class);

            startActivity(adminintent);
            action_sowing.this.finish();

            // tracks the application usage.
            ApplicationTracker.getInstance().logEvent(EventType.CLICK, LOG_TAG, "home");
          }
        });
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Look up the AdView as a resource and load a request.
    AdView adView = (AdView) this.findViewById(R.id.adView);
    adView.loadAd(new AdRequest());

    // delete button listener
    OnClickListener DeleteButtonListner =
        new OnClickListener() {
          public void onClick(View v) {
            yesnoDeleteHandler("Are you sure?", "Are you sure you want to delete?");
          }
        };
    Button deleteButton = (Button) findViewById(R.id.delete);
    deleteButton.setOnClickListener(DeleteButtonListner);

    // save button listener
    OnClickListener SaveButtonListner =
        new OnClickListener() {
          public void onClick(View v) {
            saveCurrentPyramid(v.getContext());
          }
        };
    Button saveButton = (Button) findViewById(R.id.save);
    saveButton.setOnClickListener(SaveButtonListner);

    // new button listener
    OnClickListener newButtonListner =
        new OnClickListener() {
          public void onClick(View v) {
            newPyramid();
          }
        };
    Button newPButton = (Button) findViewById(R.id.newrow);
    newPButton.setOnClickListener(newButtonListner);

    // dots button listener
    OnClickListener topDotsListner =
        new OnClickListener() {
          public void onClick(View v) {
            TextView topCheckBox = (TextView) findViewById(R.id.TopItemCheckBox);
            String blockname = topCheckBox.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsOneListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemOneCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsTwoListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemTwoCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsThreeListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemThreeCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsFourListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemFourCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsFiveListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemFiveCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsSixListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemSixCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };

    Button topDotsButton = (Button) findViewById(R.id.topdots);
    Button DotsOneButton = (Button) findViewById(R.id.dotsOne);
    Button DotsTwoButton = (Button) findViewById(R.id.dotsTwo);
    Button DotsThreeButton = (Button) findViewById(R.id.dotsThree);
    Button DotsFourButton = (Button) findViewById(R.id.dotsFour);
    Button DotsFiveButton = (Button) findViewById(R.id.dotsFive);
    Button DotsSixButton = (Button) findViewById(R.id.dotsSix);

    topDotsButton.setOnClickListener(topDotsListner);
    DotsOneButton.setOnClickListener(dotsOneListner);
    DotsTwoButton.setOnClickListener(dotsTwoListner);
    DotsThreeButton.setOnClickListener(dotsThreeListner);
    DotsFourButton.setOnClickListener(dotsFourListner);
    DotsFiveButton.setOnClickListener(dotsFiveListner);
    DotsSixButton.setOnClickListener(dotsSixListner);

    // image listeners
    // photo on click listener
    ImageView imageOne = (ImageView) findViewById(R.id.ImageViewOne);
    ImageView imageTwo = (ImageView) findViewById(R.id.ImageViewTwo);
    ImageView imageThree = (ImageView) findViewById(R.id.ImageViewThree);
    ImageView imageFour = (ImageView) findViewById(R.id.ImageViewFour);
    ImageView imageFive = (ImageView) findViewById(R.id.ImageViewFive);
    ImageView imageSix = (ImageView) findViewById(R.id.ImageViewSix);
    ImageView imageTop = (ImageView) findViewById(R.id.TopBlockImage);

    // Create an anonymous implementation of OnClickListener
    OnLongClickListener TopNameListner =
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            // do something when the button is clicked

            // in onCreate or any event where your want the user to

            AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());

            alert.setTitle("Block Name?");
            alert.setMessage("Please Enter A Name For The Block");

            // Set an EditText view to get user input
            final EditText input = new EditText(v.getContext());
            alert.setView(input);

            alert.setPositiveButton(
                "Ok",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    tempName = input.getText().toString();

                    Cursor tempCursor = getPyramidCursorByName(tempName);
                    if (tempCursor.getCount() > 0) {
                      Toast.makeText(
                              getBaseContext(), "That Name is Already In Use!", Toast.LENGTH_LONG)
                          .show();
                    } else {
                      // Do something with value!
                      if (tempName.length() > 1) {
                        // select a file
                        TextView topCheckBox = (TextView) findViewById(R.id.TopItemCheckBox);
                        topCheckBox.setText(tempName);
                      } else {
                        Toast.makeText(getBaseContext(), "Invalid Name!", Toast.LENGTH_LONG).show();
                      }
                    }
                  }
                });

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

            alert.show();
            return true;
          }
        };
    TextView topCheckBox = (TextView) findViewById(R.id.TopItemCheckBox);
    topCheckBox.setOnLongClickListener(TopNameListner);

    // checkbox listeners
    // Create an anonymous implementation of OnClickListener
    OnLongClickListener otherNameListener =
        new OnLongClickListener() {
          public boolean onLongClick(final View v) {
            // do something when the button is clicked

            // in onCreate or any event where your want the user to

            AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());

            alert.setTitle("Block Name?");
            alert.setMessage("Please Enter A Name For The Block");

            // Set an EditText view to get user input
            final EditText input = new EditText(v.getContext());
            alert.setView(input);

            alert.setPositiveButton(
                "Ok",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    tempName = input.getText().toString();

                    // Do something with value!
                    if (tempName.length() > 1) {
                      // select a file
                    } else {
                      tempName = "Unnamed";
                    }

                    // set the correct view name
                    final CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
                    final CheckBox checkBoxTwo = (CheckBox) findViewById(R.id.itemTwoCheckBox);
                    final CheckBox checkBoxThree = (CheckBox) findViewById(R.id.itemThreeCheckBox);
                    final CheckBox checkBoxFour = (CheckBox) findViewById(R.id.itemFourCheckBox);
                    final CheckBox checkBoxFive = (CheckBox) findViewById(R.id.itemFiveCheckBox);
                    final CheckBox checkBoxSix = (CheckBox) findViewById(R.id.itemSixCheckBox);

                    if (tempName != null) {
                      if (v.equals(checkBoxOne)) {
                        checkBoxOne.setText(tempName);
                      } else if (v.equals(checkBoxTwo)) {
                        checkBoxTwo.setText(tempName);
                      } else if (v.equals(checkBoxThree)) {
                        checkBoxThree.setText(tempName);
                      } else if (v.equals(checkBoxFour)) {
                        checkBoxFour.setText(tempName);
                      } else if (v.equals(checkBoxFive)) {
                        checkBoxFive.setText(tempName);
                      } else if (v.equals(checkBoxSix)) {
                        checkBoxSix.setText(tempName);
                      }
                    }
                  }
                });

            alert.setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    // Canceled.
                    tempName = null;
                  }
                });

            alert.show();

            return true;
          }
        };

    CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
    checkBoxOne.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxTwo = (CheckBox) findViewById(R.id.itemTwoCheckBox);
    checkBoxTwo.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxThree = (CheckBox) findViewById(R.id.itemThreeCheckBox);
    checkBoxThree.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxFour = (CheckBox) findViewById(R.id.itemFourCheckBox);
    checkBoxFour.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxFive = (CheckBox) findViewById(R.id.itemFiveCheckBox);
    checkBoxFive.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxSix = (CheckBox) findViewById(R.id.itemSixCheckBox);
    checkBoxSix.setOnLongClickListener(otherNameListener);

    checkBoxOne.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
            if (checkBoxOne.isChecked()) {
              checkBoxOne.setPaintFlags(checkBoxOne.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxOne.setPaintFlags(checkBoxOne.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxTwo.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxTwo = (CheckBox) findViewById(R.id.itemTwoCheckBox);
            if (checkBoxTwo.isChecked()) {
              checkBoxTwo.setPaintFlags(checkBoxTwo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxTwo.setPaintFlags(checkBoxTwo.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxThree.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxThree = (CheckBox) findViewById(R.id.itemThreeCheckBox);
            if (checkBoxThree.isChecked()) {
              checkBoxThree.setPaintFlags(
                  checkBoxThree.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxThree.setPaintFlags(
                  checkBoxThree.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxFour.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxFour = (CheckBox) findViewById(R.id.itemFourCheckBox);
            if (checkBoxFour.isChecked()) {
              checkBoxFour.setPaintFlags(
                  checkBoxFour.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxFour.setPaintFlags(
                  checkBoxFour.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxFive.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxFive = (CheckBox) findViewById(R.id.itemFiveCheckBox);
            if (checkBoxFive.isChecked()) {
              checkBoxFive.setPaintFlags(
                  checkBoxFive.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxFive.setPaintFlags(
                  checkBoxFive.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxSix.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxSix = (CheckBox) findViewById(R.id.itemSixCheckBox);
            if (checkBoxSix.isChecked()) {
              checkBoxSix.setPaintFlags(checkBoxSix.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxSix.setPaintFlags(checkBoxSix.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    // image onlongclick listeners
    imageOne.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewOne);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageTwo.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewTwo);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageThree.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewThree);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageFour.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewFour);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageFive.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewFive);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageSix.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewSix);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageTop.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.TopBlockImage);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    // set regular click listeners for the bottom 6 items
    imageOne.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageTwo.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemTwoCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageThree.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemThreeCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageFour.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemFourCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageFive.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemFiveCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageSix.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemSixCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    fillImagesRandomly();

    // set an adapter for our spinner
    m_adapterForSpinner =
        new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_item);
    m_adapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinner = (Spinner) findViewById(R.id.oldpyramids);
    spinner.setAdapter(m_adapterForSpinner);
    m_adapterForSpinner.add("*New Pyramid");

    spinner.setOnItemSelectedListener(new MyUnitsOnItemSelectedListener());

    // fill up our spinner item
    Cursor cursor = getPyramidssCursor();
    if (cursor.getCount() > 0) {
      deleteButton.setEnabled(true);
      while (cursor.moveToNext()) {
        String singlecardName = cursor.getString(1);
        m_adapterForSpinner.add(singlecardName);
      }
    } else {
      spinner.setEnabled(false);
    }
  }
示例#6
0
 @Override
 public void setOnLongClickListener(OnLongClickListener l) {
   mTriggerButton.setOnLongClickListener(l);
   mStringAnswer.setOnLongClickListener(l);
 }