コード例 #1
0
  /**
   * Constructor for add dialog.
   *
   * @param context
   * @param positive
   * @param type AddType.ITEM or AddType.LIST
   */
  protected AddDialog(
      @NonNull Context context, AddType type, DialogInterface.OnClickListener positive) {
    super(context);
    // mList = list;
    // mPosition = position;
    mContext = context;
    // mAdapter = adapter;

    mPositiveListener = positive;
    if (type == AddType.ITEM || type == AddType.LIST) {
      mType = type;
    } else {
      mType = null;
    }

    // Build the dialog and set up the button click handlers
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText titleBox = new EditText(mContext);
    titleBox.setHint("Name");
    titleBox.setId(R.id.add_dialog_title_edit);
    layout.addView(titleBox);

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    String message = "";
    String title = "Add new ";
    switch (mType) {
      case ITEM:
        title += "To-Do Item";
        message = "Please add a Name and Description to the new message";
        final EditText descriptionBox = new EditText(mContext);
        descriptionBox.setHint("Description");
        descriptionBox.setId(R.id.add_dialog_description_edit);
        layout.addView(descriptionBox);
        break;
      case LIST:
        title += "To-Do List";
        message = "Please specify a Name for your new To-Do List";
        break;
      default:
        break;
    }
    builder.setView(layout);
    builder
        .setMessage(message)
        .setTitle(title)
        .setPositiveButton("Add", mPositiveListener)
        .setNegativeButton("Cancel", null);
    builder.create();
    builder.show();
  }
コード例 #2
0
  public void showalert(int id, String path) {
    AlertDialog.Builder alert = new AlertDialog.Builder(mcontext);

    alert.setMessage("path to install");

    // Set an EditText view to get user input
    final EditText input = new EditText(mcontext);
    input.setId(id);
    input.setText(path);
    alert.setView(input);

    alert.setPositiveButton(
        "save",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            Editor edit = sharedP.edit();
            edit.putString("path" + input.getId(), input.getText().toString());
            edit.commit();
            madapt.notifyDataSetChanged();
          }
        });

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

    alert.show();
  }
コード例 #3
0
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btnAddPeople:
        final TableRow tr = new TableRow(this);
        tr.setId(1);

        EditText editText = new EditText(this);
        editText.setId(200);
        editText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        editText.setMinWidth(100);
        //			labelTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
        // LayoutParams.WRAP_CONTENT));

        tr.addView(editText);
        editText.requestFocus();

        Button deleteButton = new Button(this);
        deleteButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.delete));
        deleteButton.setId(200);
        deleteButton.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                tblPersons.removeView(tr);
              }
            });

        tr.addView(deleteButton);

        tblPersons.addView(tr);

        break;
      case R.id.btnContinue:
        String names = "";

        for (int i = 0; i < tblPersons.getChildCount(); i++) {
          TableRow row = (TableRow) tblPersons.getChildAt(i);
          String name = ((EditText) (row.getChildAt(0))).getText().toString();
          if (name != null && name.trim() != "") {
            names = names + name.trim();
          }

          if (i < tblPersons.getChildCount() - 1) {
            names = names + ",";
          }
        }

        System.out.println("!!!!!!!!!!names:" + names);

        Intent intentExpenses = new Intent();
        intentExpenses.setClassName("com.expenses", "com.expenses.ExpensesShareActivity");
        intentExpenses.putExtra("com.expenses.PersonNames", names);
        startActivity(intentExpenses);

        break;
      default:
        break;
    }
  }
コード例 #4
0
  @Override
  public Dialog onCreateDialog(final Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    // LayoutInflater inflater = LayoutInflater.from(BirdActivity.this);
    View view = inflater.inflate(R.layout.gameover, null);
    builder.setView(view);

    int highscore = getArguments().getInt("highscore");
    boolean newRecord = getArguments().getBoolean("newRecord");
    // TextView highscoretext = (TextView) view.findViewById(R.id.highscore_text);
    LinearLayout rootLayout = (LinearLayout) view.findViewById(R.id.baselinear);
    text = new EditText(getActivity());
    TextView textView = new TextView(getActivity());
    text.setId(12345);

    if (newRecord) {
      textView.setText("New highscore! Enter your name, then hit Quit or Play Again:");
      rootLayout.addView(textView);
      rootLayout.addView(text);
    } else {
      try {
        FileReader fileIn = new FileReader(HSFILENAME);
        BufferedReader buffIn = new BufferedReader(fileIn);
        String str = buffIn.readLine();
        str = buffIn.readLine();
        textView.setText(str);
        rootLayout.addView(textView);
      } catch (IOException e) {
      }
    }
    // highscoretext.setText(String.format("Highscore: %d", highscore));
    builder.setTitle("Game Over");
    builder
        .setMessage("Game over!")
        .setPositiveButton(
            "Play Again",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                mListener.onDialogPositiveClick(GameOverDialog.this);
              }
            })
        .setNegativeButton(
            "Quit",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                mListener.onDialogNegativeClick(GameOverDialog.this);
              }
            });
    // Create the AlertDialog object and return it
    return builder.create();
  }
コード例 #5
0
  /** Add a new empty input field for insert a manual beacon minor id */
  protected void addBeaconInputField() {
    LinearLayout layout = (LinearLayout) activity.findViewById(R.id.minors);

    EditText editText = new EditText(activity);
    editText.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    editText.setHint(R.string.minorId);
    editText.setId(9500 + dynamicMinorIds.size());

    editText.setSingleLine();
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();

    dynamicMinorIds.add(editText);
    layout.addView(editText);
  }
コード例 #6
0
ファイル: MainActivity.java プロジェクト: kani3012/not
  protected void createEditTextView() {
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.setMargins(0, 10, 0, 10);
    EditText edittTxt = new EditText(this);

    edittTxt.setHint("Subject Name");
    edittTxt.setLayoutParams(params);
    //
    edittTxt.setInputType(InputType.TYPE_CLASS_TEXT);
    edittTxt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    edittTxt.setId(hint);
    hint++;
    etArray.add(edittTxt);
    l.addView(edittTxt);
  }
コード例 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // layout
    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setBackgroundColor(Color.GREEN);

    // button
    Button button = new Button(this);
    button.setText("Click Me !!");
    button.setBackgroundColor(Color.RED);

    // Username Input
    EditText username = new EditText(this);

    button.setId(1);
    username.setId(2);

    RelativeLayout.LayoutParams buttonDetails =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    buttonDetails.addRule(RelativeLayout.CENTER_HORIZONTAL);
    buttonDetails.addRule(RelativeLayout.CENTER_VERTICAL);

    Resources r = getResources();
    int px =
        (int)
            TypeValue.applyDimensions(TypedValue.COMPLEX_MANTISSA_DIP, 200, r.getDisplayMetrics());

    username.setWidth(px);

    RelativeLayout.LayoutParams usernameDetails =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    usernameDetails.addRule(RelativeLayout.CENTER_HORIZONTAL);
    usernameDetails.addRule(RelativeLayout.CENTER_VERTICAL);

    //
    relativeLayout.addView(button, buttonDetails);
    setContentView(relativeLayout);
  }
コード例 #8
0
ファイル: Jacoby.java プロジェクト: jurangov/NumericsAnalisys
  private void SetUpInitialVector() {
    editTextArray = new EditText[MatrixOrder];
    ScrollView sv = new ScrollView(this);

    TableLayout ll = new TableLayout(this);
    HorizontalScrollView hsv = new HorizontalScrollView(this);

    TableRow tbrow2 = new TableRow(this);

    for (int j = 0; j < MatrixOrder; j++) {
      EditText tv2 = new EditText(this);
      tv2.setWidth(100);
      tv2.setId(j);
      tbrow2.addView(tv2);
      editTextArray[j] = tv2;
    }
    ll.addView(tbrow2);

    hsv.addView(ll);
    sv.addView(hsv);
    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearLayout2);

    linearLayout.addView(sv, 0);
  }
コード例 #9
0
ファイル: Main.java プロジェクト: LovlyN1/crocodilenote
  @SuppressWarnings("deprecation")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (isP(_P.secrecy) && !ENC) {
      setTitle("Initializing " + Main.name + "...");
      return;
    }

    Intent caller = getIntent();
    if (caller != null) {
      try {
        String tmp = caller.getStringExtra(_I.Main_setAbsoluteFolder.name());
        if (tmp == null) {
          finish();
          return;
        }
        setAbsoluteFolder(tmp);

        tmp = caller.getStringExtra(_I.Main_setFolderShowname.name());
        if (tmp == null) {
          finish();
          return;
        }
        setFolderShowname(tmp);
      } catch (Exception e) {
        e.printStackTrace();
        return;
      }
    }

    WatchImpl.enable = false;

    l1 = new RelativeLayout(this);

    int xi = 0;
    while (true) {
      if (!checkFiles(xi)) break;
      xi++;
    }
    if (xi > max) max = xi;

    thetexts = new Vector<InnerEdit>(max + 5);

    ScrollView sv = new ScrollView(this);
    l1.addView(sv);

    RelativeLayout.LayoutParams sv_lp = (RelativeLayout.LayoutParams) sv.getLayoutParams();
    sv_lp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
    sv_lp.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
    sv_lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    sv.setLayoutParams(sv_lp);

    l2 = new LinearLayout(this);
    l2.setOrientation(LinearLayout.VERTICAL);
    l2.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    sv.addView(l2);

    ArrayList<String> vals = null;
    ArrayList<Integer> ids = null;
    int newone = -1;
    int focusone = -1;

    if (caller != null) {
      if (caller.getBooleanExtra("OKAY", false)) {
        vals = caller.getStringArrayListExtra("vals");
        ids = caller.getIntegerArrayListExtra("ids");
        newone = caller.getIntExtra("newone", -1);
        focusone = caller.getIntExtra("curfocus", -1);
      }
    }

    if (newone > 0) max = newone + 1;

    setTitle(title(max));

    for (int i = 0; i < max; i++) {
      EditText t2 = new EditText(this);
      t2.setId(i);
      t2.setOnFocusChangeListener(
          new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
              if (hasFocus) curfocus = (EditText) v;
            }
          });
      t2.setImeOptions(EditorInfo.IME_ACTION_DONE);
      t2.setOnEditorActionListener(one);
      InnerEdit in = new InnerEdit(t2);
      thetexts.add(in);
      t2.addTextChangedListener(new WatchImpl(in));
      l2.addView(t2, 0);
      if (ids != null && ids.contains(i)) {
        String tmp = vals.get(ids.indexOf(i));
        if (tmp != null) t2.setText(tmp);
        else t2.setText("err");
        in.changed = true;
      } else {
        if (checkFiles(i)) {
          String x = loadFiles(i);
          t2.setText(x);
        } else {
          t2.setText("");
        }
      }

      if (focusone >= 0) {
        if (i == focusone) t2.requestFocus();
      } else {
        if (i == max - 1) t2.requestFocus();
      }
    }

    WatchImpl.enable = true;

    Button b1 = new Button(this);
    b1.setText("  Save  ");

    b1.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            int ctr = 0;
            for (int i = 0; i < max; i++) {
              if (thetexts.get(i).changed || !checkFiles(i)) {
                storeFiles(i, thetexts.get(i).edit.getText().toString());
                ctr++;
                thetexts.get(i).changed = false;
              }
            }
            Toast.makeText(me, "Saved (" + ctr + ")", Toast.LENGTH_SHORT).show();
          }
        });

    Button b2 = new Button(this);
    b2.setText("  Add  ");

    b2.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            EditText t2 = new EditText(me);
            t2.setOnFocusChangeListener(
                new OnFocusChangeListener() {

                  @Override
                  public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) curfocus = (EditText) v;
                  }
                });
            t2.setImeOptions(EditorInfo.IME_ACTION_DONE);
            t2.setOnEditorActionListener(one);

            l2.addView(t2, 0);
            t2.setId(max);
            max++;
            InnerEdit in = new InnerEdit(t2, true);
            thetexts.add(in);
            t2.addTextChangedListener(new WatchImpl(in));
            setTitle(title(max));
            t2.requestFocus();
          }
        });

    Button b3 = new Button(this);
    b3.setText("Save & Exit");
    b3.setOnClickListener(
        new OnClickListener() {
          // TODO: reduce redundancy

          @Override
          public void onClick(View v) {
            int ctr = 0;
            for (int i = 0; i < max; i++) {
              if (thetexts.get(i).changed || !checkFiles(i)) {
                storeFiles(i, thetexts.get(i).edit.getText().toString());
                ctr++;
                thetexts.get(i).changed = false;
              }
            }
            if (ctr > 0) Toast.makeText(me, "Saved (" + ctr + ")", Toast.LENGTH_SHORT).show();
            else Toast.makeText(me, "Quick Exit", Toast.LENGTH_SHORT).show();

            finish();
          }
        });

    Button b4 = new Button(this);
    b4.setText("Return");

    b4.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            for (int i = 0; i < max; i++) {
              if (thetexts.get(i).changed || !checkFiles(i)) {
                Toast.makeText(me, "unsaved data", Toast.LENGTH_SHORT).show();
                return;
              }
            }

            startActivity(new Intent(me, Startup.class));
            finish();
          }
        });

    HorizontalScrollView hori = new HorizontalScrollView(this);
    LinearLayout ll_hori = new LinearLayout(this);
    ll_hori.setOrientation(LinearLayout.HORIZONTAL);

    ll_hori.addView(b1);
    ll_hori.addView(b3);
    ll_hori.addView(b2);
    ll_hori.addView(b4);

    hori.addView(ll_hori);
    l1.addView(hori);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    hori.setLayoutParams(lp);
    hori.setId(121232);

    sv_lp = (RelativeLayout.LayoutParams) sv.getLayoutParams();
    sv_lp.addRule(RelativeLayout.ABOVE, hori.getId());
    sv.setLayoutParams(sv_lp);

    BitmapDrawable bd =
        new BitmapDrawable(
            getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.back_base));
    bd.setTileModeXY(TileMode.MIRROR, TileMode.REPEAT);
    l1.setBackgroundDrawable(bd);

    setContentView(l1);
  }
コード例 #10
0
ファイル: ScoresFragment.java プロジェクト: spjass/TH-Results
  /**
   * Generates match tables of the currently active tournament
   *
   * @param roundNumber Current round number
   */
  public void createMatchTable(int roundNumber) {

    rounds = tournament.getRounds();
    Log.d("ScoresFragment", rounds[0].getGames()[0].getAwayPlayer().getName());
    Game[] games = rounds[roundNumber - 1].getGames();
    LinearLayout linearContainerTop = new LinearLayout(getActivity().getBaseContext());
    LinearLayout.LayoutParams paramsContainerTop =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearContainerTop.setLayoutParams(paramsContainerTop);
    containerId = containerId + multiplier;
    containerIDs.add(containerId);
    linearContainerTop.setId(containerId);
    linearContainerTop.setBackgroundColor(getResources().getColor(R.color.darkgray));
    linearContainerTop.setOrientation(LinearLayout.VERTICAL);

    for (int i = 0; i < games.length; i++) {

      int id = i;
      Player homePlayer = games[i].getHomePlayer();
      Player awayPlayer = games[i].getAwayPlayer();

      LinearLayout linearContainer = new LinearLayout(getActivity().getBaseContext());
      LinearLayout.LayoutParams paramsContainer =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

      linearContainer.setLayoutParams(paramsContainer);
      linearContainer.setId(6);
      linearContainer.setBackgroundColor(getResources().getColor(R.color.darkgray));
      linearContainer.setOrientation(LinearLayout.HORIZONTAL);

      TextView homeText = new TextView(getActivity().getBaseContext());
      homeText.setId(1);
      LinearLayout.LayoutParams paramsHomeText = new LinearLayout.LayoutParams(0, 130, 0.5f);
      homeText.setGravity(Gravity.CENTER);
      paramsHomeText.setMargins(10, 10, 10, 0);
      homeText.setLayoutParams(paramsHomeText);
      homeText.setText(homePlayer.getName());
      homeText.setTextSize(18);

      TextView midText = new TextView(getActivity().getBaseContext());
      LinearLayout.LayoutParams paramsMidText =
          new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.1f);
      paramsMidText.setMargins(10, 10, 10, 0);

      midText.setGravity(Gravity.CENTER);
      midText.setLayoutParams(paramsMidText);
      midText.setId(3);
      midText.setText("-");

      LinearLayout.LayoutParams paramsAwayText = new LinearLayout.LayoutParams(0, 130, 0.5f);
      TextView awayText = new TextView(getActivity().getBaseContext());
      awayText.setId(2);
      awayText.setText(awayPlayer.getName());
      awayText.setTextSize(18);
      paramsAwayText.setMargins(10, 10, 10, 0);

      awayText.setLayoutParams(paramsAwayText);
      awayText.setGravity(Gravity.CENTER);

      EditText homeScore = new EditText(getActivity().getBaseContext());
      homeScoreId = homeScoreId + multiplier;
      homeScoreIDs.add(homeScoreId);
      LinearLayout.LayoutParams paramsHomeScore =
          new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.2f);
      homeScore.setGravity(Gravity.CENTER);
      paramsHomeScore.setMargins(10, 10, 10, 0);
      homeScore.setLayoutParams(paramsHomeScore);
      homeScore.setText(Integer.toString(games[i].getHomeScore()));
      homeScore.setInputType(InputType.TYPE_CLASS_NUMBER);
      homeScore.setId(homeScoreId);

      EditText awayScore = new EditText(getActivity().getBaseContext());
      awayScoreId = awayScoreId + multiplier;
      awayScoreIDs.add(awayScoreId);
      LinearLayout.LayoutParams paramsAwayScore =
          new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.2f);
      awayScore.setGravity(Gravity.CENTER);
      paramsAwayScore.setMargins(10, 10, 10, 0);
      awayScore.setLayoutParams(paramsAwayScore);
      awayScore.setInputType(InputType.TYPE_CLASS_NUMBER);
      awayScore.setText(Integer.toString(games[i].getAwayScore()));
      awayScore.setId(awayScoreId);

      linearContainer.addView(homeText);
      linearContainer.addView(homeScore);
      linearContainer.addView(midText);

      linearContainer.addView(awayScore);

      linearContainer.addView(awayText);
      linearContainerTop.addView(linearContainer);
    }
    layout.addView(linearContainerTop);
  }
コード例 #11
0
  protected void onCreateContent(LinearLayout parent) {
    SizeHelper.prepare(context);

    LinearLayout rlCountry = new LinearLayout(context);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(96));
    params.setMargins(
        SizeHelper.fromPx(26), SizeHelper.fromPxWidth(32), SizeHelper.fromPxWidth(26), 0);
    rlCountry.setLayoutParams(params);
    rlCountry.setId(Res.id.rl_country);

    TextView tv = new TextView(context);
    LinearLayout.LayoutParams tvParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    tvParams.gravity = Gravity.CENTER_VERTICAL;
    tv.setLayoutParams(tvParams);
    tv.setPadding(SizeHelper.fromPxWidth(14), 0, SizeHelper.fromPxWidth(14), 0);
    int resid = R.getStringRes(context, "smssdk_country");
    tv.setText(resid);
    tv.setTextColor(0xff000000);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    rlCountry.addView(tv);

    TextView tvCountry = new TextView(context);
    tvCountry.setId(Res.id.tv_country);
    LinearLayout.LayoutParams tvCountryParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    tvCountryParams.gravity = Gravity.CENTER_VERTICAL;
    tvCountryParams.weight = 1;
    tvCountryParams.rightMargin = SizeHelper.fromPxWidth(14);
    tvCountry.setLayoutParams(tvCountryParams);
    tvCountry.setGravity(Gravity.RIGHT);
    tvCountry.setPadding(SizeHelper.fromPxWidth(14), 0, SizeHelper.fromPxWidth(14), 0);
    tvCountry.setTextColor(0xff45c01a);
    tvCountry.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    rlCountry.addView(tvCountry);

    parent.addView(rlCountry);

    View line = new View(context);
    LinearLayout.LayoutParams lineParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, SizeHelper.fromPxWidth(1));
    lineParams.leftMargin = SizeHelper.fromPxWidth(26);
    lineParams.rightMargin = SizeHelper.fromPxWidth(26);
    line.setLayoutParams(lineParams);
    line.setBackgroundColor(Res.color.smssdk_gray_press);
    parent.addView(line);

    LinearLayout phoneLayout = new LinearLayout(context);
    LinearLayout.LayoutParams phoneParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(70));
    phoneParams.setMargins(
        SizeHelper.fromPxWidth(26), SizeHelper.fromPxWidth(30), SizeHelper.fromPxWidth(26), 0);
    phoneLayout.setLayoutParams(phoneParams);

    TextView countryNum = new TextView(context);
    countryNum.setId(Res.id.tv_country_num);
    LinearLayout.LayoutParams countryNumParams =
        new LinearLayout.LayoutParams(
            SizeHelper.fromPxWidth(104), LinearLayout.LayoutParams.MATCH_PARENT);
    countryNum.setLayoutParams(countryNumParams);
    countryNum.setGravity(Gravity.CENTER);
    countryNum.setTextColor(0xff353535);
    countryNum.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    resid = R.getBitmapRes(context, "smssdk_input_bg_focus");
    countryNum.setBackgroundResource(resid);
    phoneLayout.addView(countryNum);

    LinearLayout wrapperLayout = new LinearLayout(context);
    LinearLayout.LayoutParams wrapperParams =
        new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
    wrapperParams.weight = 1;
    wrapperLayout.setLayoutParams(wrapperParams);
    resid = R.getBitmapRes(context, "smssdk_input_bg_special_focus");
    wrapperLayout.setBackgroundResource(resid);

    EditText writePhone = new EditText(context);
    writePhone.setId(Res.id.et_write_phone);
    LinearLayout.LayoutParams writePhoneParams =
        new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT);
    writePhoneParams.gravity = Gravity.CENTER_VERTICAL;
    writePhoneParams.setMargins(SizeHelper.fromPxWidth(10), 0, SizeHelper.fromPxWidth(10), 0);
    writePhoneParams.weight = 1;
    writePhone.setLayoutParams(writePhoneParams);
    writePhone.setBackgroundDrawable(null);
    resid = R.getStringRes(context, "smssdk_write_mobile_phone");
    writePhone.setHint(resid);
    writePhone.setInputType(InputType.TYPE_CLASS_PHONE);
    writePhone.setTextColor(0xff353535);
    writePhone.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    wrapperLayout.addView(writePhone);

    ImageView image = new ImageView(context);
    image.setId(Res.id.iv_clear);
    LinearLayout.LayoutParams imageParams =
        new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(24), SizeHelper.fromPxWidth(24));
    imageParams.gravity = Gravity.CENTER_VERTICAL;
    imageParams.rightMargin = SizeHelper.fromPxWidth(20);
    image.setLayoutParams(imageParams);
    resid = R.getBitmapRes(context, "smssdk_clear_search");
    image.setBackgroundResource(resid);
    image.setScaleType(ScaleType.CENTER_INSIDE);
    image.setVisibility(View.GONE);
    wrapperLayout.addView(image);
    phoneLayout.addView(wrapperLayout);
    parent.addView(phoneLayout);

    Button nextBtn = new Button(context);
    nextBtn.setId(Res.id.btn_next);
    LinearLayout.LayoutParams nextParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(72));
    nextParams.setMargins(
        SizeHelper.fromPxWidth(26), SizeHelper.fromPxWidth(36), SizeHelper.fromPxWidth(26), 0);
    nextBtn.setLayoutParams(nextParams);
    resid = R.getBitmapRes(context, "smssdk_btn_disenable");
    nextBtn.setBackgroundResource(resid);
    resid = R.getStringRes(context, "smssdk_next");
    nextBtn.setText(resid);
    nextBtn.setTextColor(0xffffffff);
    nextBtn.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    nextBtn.setPadding(0, 0, 0, 0);
    parent.addView(nextBtn);
  }
コード例 #12
0
ファイル: SGTPuzzles.java プロジェクト: nbzhou/sgtpuzzles
 void dialogAdd(int id, int type, String name, String value, int selection) {
   switch (type) {
     case C_STRING:
       {
         dialogIds.add(id);
         EditText et = new EditText(SGTPuzzles.this);
         // TODO: C_INT, C_UINT, C_UDOUBLE, C_DOUBLE
         // Ugly temporary hack: in custom game dialog, all text boxes are numeric, in the other
         // two dialogs they aren't.
         // Uglier temporary-er hack: Black Box must accept a range for ball count.
         if (configIsCustom && !helpTopic.equals("blackbox"))
           et.setInputType(
               InputType.TYPE_CLASS_NUMBER
                   | InputType.TYPE_NUMBER_FLAG_DECIMAL
                   | InputType.TYPE_NUMBER_FLAG_SIGNED);
         et.setId(id);
         et.setText(value);
         TextView tv = new TextView(SGTPuzzles.this);
         tv.setText(name);
         tv.setPadding(2, 2, 2, 2);
         TableRow tr = new TableRow(SGTPuzzles.this);
         tr.addView(tv);
         tr.addView(et);
         dialogLayout.addView(tr);
         break;
       }
     case C_BOOLEAN:
       {
         dialogIds.add(id);
         CheckBox c = new CheckBox(SGTPuzzles.this);
         c.setId(id);
         c.setText(name);
         c.setChecked(selection != 0);
         dialogLayout.addView(c);
         break;
       }
     case C_CHOICES:
       {
         StringTokenizer st = new StringTokenizer(value.substring(1), value.substring(0, 1));
         ArrayList<String> choices = new ArrayList<String>();
         while (st.hasMoreTokens()) choices.add(st.nextToken());
         dialogIds.add(id);
         Spinner s = new Spinner(SGTPuzzles.this);
         s.setId(id);
         ArrayAdapter<String> a =
             new ArrayAdapter<String>(
                 SGTPuzzles.this,
                 android.R.layout.simple_spinner_item,
                 choices.toArray(new String[0]));
         a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         s.setAdapter(a);
         s.setSelection(selection);
         TextView tv = new TextView(SGTPuzzles.this);
         tv.setText(name);
         TableRow tr = new TableRow(SGTPuzzles.this);
         tr.addView(tv);
         tr.addView(s);
         dialogLayout.addView(tr);
         break;
       }
   }
 }
コード例 #13
0
  @Override
  public void setValues(
      DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly, ViewIdGenerator vig) {
    super.setValues(kind, entry, state, readOnly, vig);
    // Remove edit texts that we currently have
    if (mFieldEditTexts != null) {
      for (EditText fieldEditText : mFieldEditTexts) {
        mFields.removeView(fieldEditText);
      }
      mFieldEditTexts = null;
    }
    if (localGroupsSelectors != null) {
      for (View view : localGroupsSelectors) {
        mFields.removeView(view);
      }
      localGroupsSelectors = null;
    }
    boolean hidePossible = false;

    int fieldCount = kind.fieldList.size();
    if (LocalGroup.CONTENT_ITEM_TYPE.equals(kind.mimeType))
      localGroupsSelectors = new LocalGroupsSelector[fieldCount];
    else mFieldEditTexts = new EditText[fieldCount];
    for (int index = 0; index < fieldCount; index++) {
      final EditField field = kind.fieldList.get(index);
      if (LocalGroup.CONTENT_ITEM_TYPE.equals(kind.mimeType)) {
        final LocalGroupsSelector localGroupsSelector =
            new LocalGroupsSelector(mContext, entry, field.column);
        localGroupsSelector.setOnGroupSelectListener(
            new OnGroupSelectListener() {
              @Override
              public void onGroupChanged() {
                setDeleteButtonVisible(localGroupsSelector.getGroupId() > -1);
              }
            });
        // Show the delete button if we have a non-null value
        setDeleteButtonVisible(localGroupsSelector.getGroupId() > -1);
        localGroupsSelectors[index] = localGroupsSelector;
        mFields.addView(localGroupsSelector);
      } else {
        final EditText fieldView = new EditText(mContext);
        /*Begin: Modified by bxinchun for change the layout 2012/07/24*/
        /*Begin: Modified by xiepengfei for change the layout 2012/05/02*/
        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT,
                field.isMultiLine() ? LayoutParams.WRAP_CONTENT : mMinFieldHeight);
        params.bottomMargin = 10;
        fieldView.setLayoutParams(params);
        /*End: Modified by xiepengfei for change the layout 2012/05/02*/
        /*End: Modified by bxinchun for change the layout 2012/07/24*/

        // Set either a minimum line requirement or a minimum height (because {@link TextView}
        // only takes one or the other at a single time).
        if (field.minLines != 0) {
          fieldView.setMinLines(field.minLines);
        } else {
          fieldView.setMinHeight(mMinFieldHeight);
        }
        fieldView.setTextAppearance(getContext(), android.R.style.TextAppearance_Medium);
        fieldView.setGravity(Gravity.TOP);
        /*Begin: Modified by xiepengfei for change the layout 2012/05/02*/
        fieldView.setBackgroundResource(R.drawable.edit_editor_background);
        fieldView.setTextSize(20);
        fieldView.setTextColor(Color.BLACK);
        /*End: Modified by xiepengfei for change the layout 2012/05/02*/
        mFieldEditTexts[index] = fieldView;
        fieldView.setId(vig.getId(state, kind, entry, index));
        if (field.titleRes > 0) {
          fieldView.setHint(field.titleRes);
        }
        int inputType = field.inputType;
        fieldView.setInputType(inputType);
        if (inputType == InputType.TYPE_CLASS_PHONE) {
          PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(mContext, fieldView);
        }

        // Show the "next" button in IME to navigate between text fields
        // TODO: Still need to properly navigate to/from sections without text fields,
        // See Bug: 5713510
        fieldView.setImeOptions(EditorInfo.IME_ACTION_NEXT);

        // Read current value from state
        final String column = field.column;
        final String value = entry.getAsString(column);
        fieldView.setText(value);

        // Show the delete button if we have a non-null value
        setDeleteButtonVisible(value != null);

        // Prepare listener for writing changes
        fieldView.addTextChangedListener(
            new TextWatcher() {
              @Override
              public void afterTextChanged(Editable s) {
                // Trigger event for newly changed value
                onFieldChanged(column, s.toString());
              }

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

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

        fieldView.setEnabled(isEnabled() && !readOnly);

        if (field.shortForm) {
          hidePossible = true;
          mHasShortAndLongForms = true;
          fieldView.setVisibility(mHideOptional ? View.VISIBLE : View.GONE);
        } else if (field.longForm) {
          hidePossible = true;
          mHasShortAndLongForms = true;
          fieldView.setVisibility(mHideOptional ? View.GONE : View.VISIBLE);
        } else {
          // Hide field when empty and optional value
          final boolean couldHide = (!ContactsUtils.isGraphic(value) && field.optional);
          final boolean willHide = (mHideOptional && couldHide);
          fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
          hidePossible = hidePossible || couldHide;
        }

        mFields.addView(fieldView);
      }
    }

    // When hiding fields, place expandable
    setupExpansionView(hidePossible, mHideOptional);
    mExpansionView.setEnabled(!readOnly && isEnabled());
  }
コード例 #14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.v("TAG", "in onCreate of FinishTransactionActivity");

    mApplication = (GroupBankerApplication) getApplication();

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();

    mTransactionDbHelper = new TransactionDbAdapter(this);
    mTransactionDbHelper.open();

    detailsHelper = new DetailsDbAdapter(this);
    detailsHelper.open();

    overviewHelper = new overviewDbAdapter(this);
    overviewHelper.open();

    mInfoDbAdapter = new InfoDbAdapter(this);
    mInfoDbAdapter.open();

    description = bundle.getString("description");
    overviewBundle.putString("description", description);

    amount = bundle.getString("amount");
    amount1 = Float.valueOf(amount);
    overviewBundle.putFloat("amount", amount1);

    selectedIds = bundle.getStringArray("selectedIds");

    ScrollView scrollView = new ScrollView(this);
    RelativeLayout relativeLayout = new RelativeLayout(this);
    scrollView.addView(relativeLayout);

    mDescription = new TextView(this);

    mAmount = new TextView(this);

    mDescription.setText(description);
    mDescription.setId(mID); // Set a random id for alignment

    mAmount.setText("Amount = Rs. " + amount);
    mAmount.setId(getId());

    final RelativeLayout.LayoutParams paramsDescription =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsDescription.addRule(RelativeLayout.ALIGN_LEFT);

    final RelativeLayout.LayoutParams paramsAmount =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsAmount.addRule(RelativeLayout.ALIGN_LEFT);
    paramsAmount.addRule(RelativeLayout.BELOW, mDescription.getId());

    relativeLayout.addView(mDescription, paramsDescription);
    relativeLayout.addView(mAmount, paramsAmount);

    TextView formTitle = new TextView(this);
    formTitle.setId(getId());
    formTitle.setText(R.string.finish_question);

    final RelativeLayout.LayoutParams paramsFormTitle =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsFormTitle.addRule(RelativeLayout.BELOW, mAmount.getId());

    relativeLayout.addView(formTitle, paramsFormTitle);

    /* Set up a separate textview and edittext for the user
     * We are getting username from GroupBankerApplication
     */

    TextView userName = new TextView(this);
    userName.setId(getId());
    userName.setText(mApplication.getUserName());
    Log.v(TAG, "username value:" + mApplication.getUserName());
    userName.setPadding(10, 30, 60, 0);

    final RelativeLayout.LayoutParams paramsUserName =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsUserName.addRule(RelativeLayout.ALIGN_LEFT);
    paramsUserName.addRule(RelativeLayout.BELOW, formTitle.getId());
    relativeLayout.addView(userName, paramsUserName);

    userPaid = new EditText(this);
    userPaid.setId(getId());
    userPaid.setInputType(InputType.TYPE_CLASS_NUMBER); // takes only number input
    userPaid.setHint(R.string.paidHint);

    // TODO Will be good if we can control the width without hardcoding

    final RelativeLayout.LayoutParams paramsUserPaid =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsUserPaid.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    paramsUserPaid.addRule(RelativeLayout.RIGHT_OF, userName.getId());
    paramsUserPaid.addRule(RelativeLayout.ALIGN_TOP, userName.getId());
    relativeLayout.addView(userPaid, paramsUserPaid);

    // Now lets set the textViews and edittexts for all who have paid

    names = new TextView[selectedIds.length];
    paid = new EditText[selectedIds.length];
    TextView rowTextView;
    EditText rowEditText;
    int i;

    for (i = 0; i < selectedIds.length; i++) {
      rowTextView = new TextView(this);
      rowTextView.setId(getId());

      rowEditText = new EditText(this);
      rowEditText.setId(getId());
      rowEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
      rowEditText.setHint(R.string.paidHint);

      String name = mApplication.getFriendsDbAdapter().fetchFriendName(selectedIds[i]);
      rowTextView.setText(name);

      // rowTextView.setMinimumWidth(50);
      rowTextView.setPadding(10, 30, 60, 0);

      //	rowEditText.setMinWidth(200);

      final RelativeLayout.LayoutParams paramsTextView =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

      final RelativeLayout.LayoutParams paramsEditText =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      paramsEditText.addRule(RelativeLayout.RIGHT_OF, rowTextView.getId());
      paramsEditText.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      paramsEditText.addRule(RelativeLayout.ALIGN_TOP, rowTextView.getId());
      paramsEditText.setMargins(2, 20, 2, 20);

      // The first TextView will be below userName TextView. Rest below names[i-1]
      if (i == 0) {
        paramsTextView.addRule(RelativeLayout.BELOW, userName.getId());
      } else {
        paramsTextView.addRule(RelativeLayout.BELOW, names[i - 1].getId());
        // paramsEditText.addRule(RelativeLayout.BELOW, paid[i-1].getId());
      }
      paramsTextView.addRule(RelativeLayout.ALIGN_LEFT);

      relativeLayout.addView(rowTextView, paramsTextView);
      relativeLayout.addView(rowEditText, paramsEditText);

      names[i] = rowTextView;
      paid[i] = rowEditText;
    }

    Button btn = new Button(this);
    btn.setText(R.string.finishTransaction);
    btn.setId(getId());
    btn.setOnClickListener(this);
    final RelativeLayout.LayoutParams paramsButton =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsButton.addRule(RelativeLayout.BELOW, names[selectedIds.length - 1].getId());
    paramsButton.addRule(RelativeLayout.BELOW, paid[selectedIds.length - 1].getId());

    relativeLayout.addView(btn, paramsButton);
    mrelativeLayout = relativeLayout;

    this.setContentView(scrollView);
  }
コード例 #15
0
  @Override
  public void setValues(
      DataKind kind,
      ValuesDelta entry,
      RawContactDelta state,
      boolean readOnly,
      ViewIdGenerator vig) {
    super.setValues(kind, entry, state, readOnly, vig);
    // Remove edit texts that we currently have
    if (mFieldEditTexts != null) {
      for (EditText fieldEditText : mFieldEditTexts) {
        mFields.removeView(fieldEditText);
      }
    }
    boolean hidePossible = false;

    int fieldCount = kind.fieldList.size();
    mFieldEditTexts = new EditText[fieldCount];
    for (int index = 0; index < fieldCount; index++) {
      final EditField field = kind.fieldList.get(index);
      final EditText fieldView = new EditText(mContext);
      fieldView.setLayoutParams(
          new LinearLayout.LayoutParams(
              LayoutParams.MATCH_PARENT,
              field.isMultiLine() ? LayoutParams.WRAP_CONTENT : mMinFieldHeight));
      // Set either a minimum line requirement or a minimum height (because {@link TextView}
      // only takes one or the other at a single time).
      if (field.minLines != 0) {
        fieldView.setMinLines(field.minLines);
      } else {
        fieldView.setMinHeight(mMinFieldHeight);
      }
      fieldView.setTextAppearance(getContext(), android.R.style.TextAppearance_Medium);
      fieldView.setGravity(Gravity.TOP);
      mFieldEditTexts[index] = fieldView;
      fieldView.setId(vig.getId(state, kind, entry, index));

      if (field.titleRes > 0) {
        fieldView.setHint(field.titleRes);
      }
      /** M:AAS @ { update fieldView's hint text */
      if (Phone.CONTENT_ITEM_TYPE.equals(kind.mimeType)) {
        int type = SimUtils.isAdditionalNumber(entry) ? 1 : 0;
        ExtensionManager.getInstance()
            .getContactDetailExtension()
            .updateView(
                fieldView,
                type,
                ContactDetailExtension.VIEW_UPDATE_HINT,
                ExtensionManager.COMMD_FOR_AAS);
      }
      /** M: @ } */

      /** M: New Feature xxx @{ */
      /* original code int inputType = field.inputType; */
      final int inputType = field.inputType;
      /** @} */
      fieldView.setInputType(inputType);
      if (inputType == InputType.TYPE_CLASS_PHONE) {
        /** M: New Feature xxx @{ */
        /*
         * original code
         * PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher
         * (mContext, fieldView);
         */
        // add by mediatek
        ExtensionManager.getInstance()
            .getContactDetailExtension()
            .setViewKeyListener(fieldView, ContactPluginDefault.COMMD_FOR_OP01);
        PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(mContext, fieldView, null);
        /** @} */
      }

      // Show the "next" button in IME to navigate between text fields
      // TODO: Still need to properly navigate to/from sections without text fields,
      // See Bug: 5713510
      fieldView.setImeOptions(EditorInfo.IME_ACTION_NEXT);

      // Read current value from state
      final String column = field.column;
      final String value = entry.getAsString(column);

      /*
       * Bug Fix by Mediatek Begin.
       *   Original Android's code:
       *     xxx
       *   CR ID: ALPS00244669
       *   Descriptions:
       */
      Log.i(TAG, "setValues setFilter");
      fieldView.setFilters(new InputFilter[] {new InputFilter.LengthFilter(FIELD_VIEW_MAX)});
      /*
       * Bug Fix by Mediatek End.
       */

      fieldView.setText(value);

      // Show the delete button if we have a non-null value
      setDeleteButtonVisible(value != null);

      // Prepare listener for writing changes
      fieldView.addTextChangedListener(
          new TextWatcher() {
            /** M: New Feature xxx @{ */
            int location = 0;

            /** @} */
            @Override
            public void afterTextChanged(Editable s) {
              // Trigger event for newly changed value
              /** M: New Feature Easy Porting @{ */
              /* original code onFieldChanged(column, s.toString()); */
              String phoneText = s.toString();
              phoneText =
                  ExtensionManager.getInstance()
                      .getContactDetailExtension()
                      .TextChanged(
                          inputType, s, phoneText, location, ContactPluginDefault.COMMD_FOR_OP01);
              onFieldChanged(column, phoneText);
              /** @} */
            }

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

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

      fieldView.setEnabled(isEnabled() && !readOnly);

      if (field.shortForm) {
        hidePossible = true;
        mHasShortAndLongForms = true;
        fieldView.setVisibility(mHideOptional ? View.VISIBLE : View.GONE);
      } else if (field.longForm) {
        hidePossible = true;
        mHasShortAndLongForms = true;
        fieldView.setVisibility(mHideOptional ? View.GONE : View.VISIBLE);
      } else {
        // Hide field when empty and optional value
        final boolean couldHide = (!ContactsUtils.isGraphic(value) && field.optional);
        final boolean willHide = (mHideOptional && couldHide);
        fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
        hidePossible = hidePossible || couldHide;
      }

      mFields.addView(fieldView);
    }

    // When hiding fields, place expandable
    setupExpansionView(hidePossible, mHideOptional);
    mExpansionView.setEnabled(!readOnly && isEnabled());
  }
コード例 #16
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Custom Regex");

    final TextView regexLabel = new TextView(getActivity());
    regexLabel.setText("Enter the Regex to match");
    int paddingE = getResources().getDimensionPixelOffset(R.dimen.card_external_padding);
    int paddingI = getResources().getDimensionPixelOffset(R.dimen.card_internal_padding);
    regexLabel.setPadding(paddingI, paddingI, paddingI, 0);

    // Use an EditText view to get user input.
    final EditText input = new EditText(getActivity());
    input.setId(0);
    input.setSingleLine(true);
    input.setPadding(paddingI, 0, paddingI, 0);

    final TextView secondsLabel = new TextView(getActivity());
    secondsLabel.setText("Enter the interval in seconds");
    secondsLabel.setPadding(paddingI, paddingE, paddingI, 0);

    final EditText secondsEdit = new EditText(getActivity());
    secondsEdit.setSingleLine(true);
    secondsEdit.setInputType(InputType.TYPE_CLASS_NUMBER);
    secondsEdit.setPadding(paddingI, 0, paddingI, paddingI);

    LinearLayout parentView = new LinearLayout(getActivity());
    parentView.setOrientation(LinearLayout.VERTICAL);
    ViewGroup.LayoutParams LLParams =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    parentView.setLayoutParams(LLParams);
    parentView.addView(regexLabel);
    parentView.addView(input);
    parentView.addView(secondsLabel);
    parentView.addView(secondsEdit);

    builder.setView(parentView);

    if (mDefaultValue != null) {
      input.setText(mDefaultValue);
    }

    if (mDefaultSeconds != null) {
      secondsEdit.setText(mDefaultSeconds.toString());
    }

    builder.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            String seconds = secondsEdit.getText().toString();
            // Set value in Prefs and reload them for the list.
            SharedPreferences prefs =
                getActivity()
                    .getSharedPreferences(
                        "com.ryansteckler.nlpunbounce_preferences", Context.MODE_WORLD_READABLE);
            Set<String> sampleSet = new HashSet<String>();
            Set<String> set =
                new HashSet<String>(prefs.getStringSet(mDefaultSetName + "_regex_set", sampleSet));
            set.add(value + "$$||$$" + seconds);
            if (mDefaultValue != "") {
              set.remove(mDefaultValue + "$$||$$" + mDefaultSeconds);
            }

            SharedPreferences.Editor edit = prefs.edit();
            edit.putStringSet(mDefaultSetName + "_regex_set", set);
            edit.commit();
            ((WakelockRegexFragment) (getTargetFragment())).reload();
            return;
          }
        });

    builder.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            return;
          }
        });

    return builder.create();
  }
コード例 #17
0
ファイル: NewSMSActivity.java プロジェクト: wwhui/BYOD
  private void initMyGroupView() {
    ll = (LinearLayout) findViewById(R.id.l1);
    DisplayMetrics metric = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metric);
    /**
     * *******************************************************************************************
     */
    mvg = new MyViewGroup(NewSMSActivity.this);
    mvg.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 70));
    //		mvg.setBackgroundColor(Color.GREEN);
    etMess = new EditText(NewSMSActivity.this);
    etMess.setFilters(new InputFilter[] {new InputFilter.LengthFilter(15)});
    etMess.setSelection(etMess.getText().length());
    etMess.setGravity(Gravity.CENTER_VERTICAL);
    etMess.setMinWidth(100);
    etMess.setHeight(60);
    etMess.setTag("edit");
    etMess.getBackground().setAlpha(0);
    etMess.setId(extiTextId);
    etMess.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {

            if (isNum(s.toString())) {
              if (s.length() >= 1) {
                boolean bool = false;
                // length() == 15直接生成按钮
                if (s.length() == 15) {
                  bool = true;
                }
                // 字数没有满足15个验证是否有空格
                if (!bool) {
                  String c = s.toString().substring(start, start + count);
                  for (int i = 0; i < chars.length; i++) {
                    if (chars[i].equals(c)) {
                      bool = true;
                      break;
                    }
                  }
                }
                // bool == true 生成Button
                if (bool) {
                  createView1(s.toString(), s.toString());
                  etMess.setText("");
                }
                // 检测输入框数据是否已经换行
                final View child = mvg.getChildAt(mvg.getChildCount() - 1);
                autoHeight(child);
              }
            } else {
              adapter.getFilter().filter(s);
              queryListView.setVisibility(View.VISIBLE);
            }
          }

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

          @Override
          public void afterTextChanged(Editable s) {}
        });
    mvg.addView(etMess);
    ll.addView(mvg);
    etMess.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              if (isNum(etMess.getText().toString().trim())) {
                createView1(etMess.getText().toString().trim(), etMess.getText().toString().trim());
                etMess.setText("");
              } else {
                etMess.setText("");
                queryListView.setVisibility(View.INVISIBLE);
              }
            }
          }
        });
  }
コード例 #18
0
  @SuppressWarnings("deprecation")
  private void init(Context context, int initialColor) {
    setPadding(UI.dialogMargin, UI.dialogMargin, UI.dialogMargin, UI.dialogMargin);
    final int eachW = (UI._18sp * 7) >> 1;
    final boolean smallScreen = (UI.isLowDpiScreen && !UI.isLargeScreen);
    initialColor = 0xff000000 | (initialColor & 0x00ffffff);
    hsv = new HSV();
    hsv.fromRGB(initialColor);
    hsvTmp = new HSV();
    bmpRect = new Rect(0, 0, 1, 1);
    this.initialColor = initialColor;
    currentColor = initialColor;
    sliderColor = (UI.isAndroidThemeLight() ? 0xff000000 : 0xffffffff);
    final LinearLayout l = new LinearLayout(context);
    l.setId(1);
    l.setWeightSum(2);
    LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    addView(l, p);
    final TextView lbl = new TextView(context);
    lbl.setBackgroundDrawable(new ColorDrawable(initialColor));
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            smallScreen ? (UI.defaultControlSize) >> 1 : UI.defaultControlSize);
    lp.weight = 1;
    lp.rightMargin = UI.controlSmallMargin;
    l.addView(lbl, lp);
    bgCurrent = new ColorDrawable(initialColor);
    lblCurrent = new TextView(context);
    lblCurrent.setBackgroundDrawable(bgCurrent);
    lp =
        new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            smallScreen ? (UI.defaultControlSize) >> 1 : UI.defaultControlSize);
    lp.weight = 1;
    lp.leftMargin = UI.controlSmallMargin;
    l.addView(lblCurrent, lp);

    final int textSize = (smallScreen ? UI._14sp : UI._18sp);
    TextView lblTit = new TextView(context);
    lblTit.setId(2);
    lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    lblTit.setSingleLine();
    lblTit.setGravity(Gravity.CENTER);
    lblTit.setText("H");
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.BELOW, 1);
    addView(lblTit, p);
    lblTit = new TextView(context);
    lblTit.setId(3);
    lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    lblTit.setSingleLine();
    lblTit.setGravity(Gravity.CENTER);
    lblTit.setText("S");
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.BELOW, 1);
    addView(lblTit, p);
    lblTit = new TextView(context);
    lblTit.setId(4);
    lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    lblTit.setSingleLine();
    lblTit.setGravity(Gravity.CENTER);
    lblTit.setText("V");
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.BELOW, 1);
    addView(lblTit, p);

    barH = new BgSeekBar(context);
    barH.setId(5);
    barH.setMax(360);
    barH.setValue((int) (hsv.h * 360.0));
    barH.setSliderMode(true);
    barH.setVertical(true);
    p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.leftMargin = ((eachW - UI.defaultControlSize) >> 1);
    p.addRule(RelativeLayout.ALIGN_LEFT, 2);
    p.addRule(RelativeLayout.BELOW, 2);
    p.addRule(RelativeLayout.ABOVE, 6);
    addView(barH, p);
    barS = new BgSeekBar(context);
    barS.setMax(100);
    barS.setValue((int) (hsv.s * 100.0));
    barS.setSliderMode(true);
    barS.setVertical(true);
    p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.leftMargin = ((eachW - UI.defaultControlSize) >> 1);
    p.addRule(RelativeLayout.ALIGN_LEFT, 3);
    p.addRule(RelativeLayout.BELOW, 3);
    p.addRule(RelativeLayout.ABOVE, 6);
    addView(barS, p);
    barV = new BgSeekBar(context);
    barV.setMax(100);
    barV.setValue((int) (hsv.v * 100.0));
    barV.setSliderMode(true);
    barV.setVertical(true);
    p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.leftMargin = ((eachW - UI.defaultControlSize) >> 1);
    p.addRule(RelativeLayout.ALIGN_LEFT, 4);
    p.addRule(RelativeLayout.BELOW, 4);
    p.addRule(RelativeLayout.ABOVE, 6);
    addView(barV, p);

    txtH = new EditText(context);
    txtH.setId(6);
    txtH.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txtH.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtH.setSingleLine();
    txtH.setGravity(Gravity.CENTER);
    txtH.setText(Integer.toString((int) (hsv.h * 360.0)));
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ABOVE, 7);
    addView(txtH, p);
    txtS = new EditText(context);
    txtS.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txtS.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtS.setSingleLine();
    txtS.setGravity(Gravity.CENTER);
    txtS.setText(Integer.toString((int) (hsv.s * 100.0)));
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ABOVE, 7);
    addView(txtS, p);
    txtV = new EditText(context);
    txtV.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txtV.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtV.setSingleLine();
    txtV.setGravity(Gravity.CENTER);
    txtV.setText(Integer.toString((int) (hsv.v * 100.0)));
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ABOVE, 7);
    addView(txtV, p);

    txt = new EditText(context);
    txt.setId(7);
    txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txt.setSingleLine();
    txt.setGravity(Gravity.CENTER);
    txt.setText(ColorUtils.toHexColor(initialColor));
    p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    addView(txt, p);

    lbl.setOnClickListener(this);
    barH.setOnBgSeekBarChangeListener(this);
    barH.setOnBgSeekBarDrawListener(this);
    barS.setOnBgSeekBarChangeListener(this);
    barS.setOnBgSeekBarDrawListener(this);
    barV.setOnBgSeekBarChangeListener(this);
    barV.setOnBgSeekBarDrawListener(this);
    txtH.addTextChangedListener(this);
    txtS.addTextChangedListener(this);
    txtV.addTextChangedListener(this);
    txt.addTextChangedListener(this);
  }
コード例 #19
0
  @Override
  public void createControl(TitaniumModuleManager tmm) {
    tv = new EditText(tmm.getAppContext());
    tv.isFocusable();
    tv.setId(100);

    tv.addTextChangedListener(this);
    tv.setOnEditorActionListener(this);
    tv.setText(value);
    tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    tv.setPadding(4, 2, 4, 2);
    tv.setSingleLine();
    TitaniumUIHelper.styleText(tv, fontSize, fontWeight);

    if (color != null) {
      tv.setTextColor(TitaniumColorHelper.parseColor(color));
    }
    if (backgroundColor != null) {
      tv.setBackgroundColor(TitaniumColorHelper.parseColor(backgroundColor));
    }

    cancelBtn = new ImageButton(tmm.getAppContext());
    cancelBtn.isFocusable();
    cancelBtn.setId(101);
    cancelBtn.setPadding(0, 0, 0, 0);
    Drawable d = new BitmapDrawable(this.getClass().getResourceAsStream("cancel.png"));
    cancelBtn.setImageDrawable(d);
    cancelBtn.setMinimumWidth(48);

    cancelBtn.setVisibility(showCancel ? View.VISIBLE : View.GONE);
    cancelBtn.setOnClickListener(
        new OnClickListener() {

          public void onClick(View view) {
            handler.sendEmptyMessage(MSG_CANCEL);
          }
        });

    RelativeLayout layout = new RelativeLayout(tmm.getAppContext());
    control = layout;

    layout.setGravity(Gravity.NO_GRAVITY);
    layout.setPadding(0, 0, 0, 0);
    if (barColor != null) {
      layout.setBackgroundColor(TitaniumColorHelper.parseColor(barColor));
    }

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.addRule(RelativeLayout.LEFT_OF, 101);
    params.setMargins(4, 4, 0, 4);
    layout.addView(tv, params);

    params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.setMargins(0, 4, 4, 4);
    layout.addView(cancelBtn, params);
  }
コード例 #20
0
ファイル: RelevarActivity.java プロジェクト: pgeorge27/tdc
  private View getView(int mId, cl.tdc.felipe.tdc.objects.Relevar.Item item) {
    String type = item.getType();
    List<String> values = item.getValues();
    LinearLayout contenido = new LinearLayout(this);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    contenido.setLayoutParams(params);
    params.setMargins(0, 6, 0, 0);
    contenido.setOrientation(LinearLayout.VERTICAL);
    contenido.setGravity(Gravity.CENTER_HORIZONTAL);
    String comment = "";

    if (type.equals("SELECT")) {
      Spinner s = new Spinner(this);
      s.setBackgroundResource(R.drawable.spinner_bg);
      s.setLayoutParams(
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      ArrayAdapter<String> adapter =
          new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, values);
      s.setAdapter(adapter);
      String id = mId + item.getId() + item.getName() + values.toString();
      s.setId(Funciones.str2int(id));
      String Selected = reg.getString("SELECT" + s.getId());
      s.setSelection(adapter.getPosition(Selected));
      contenido.addView(s);
      item.setVista(s);

      comment = reg.getString("COMMENTSELECT" + s.getId());

    } else if (type.equals("CHECK")) {
      LinearLayout checkboxLayout = new LinearLayout(this);
      checkboxLayout.setLayoutParams(
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      checkboxLayout.setOrientation(LinearLayout.VERTICAL);
      ArrayList<CheckBox> checkBoxes = new ArrayList<>();
      int count = 0;
      while (count < values.size()) {
        LinearLayout dump = new LinearLayout(this);
        dump.setOrientation(LinearLayout.HORIZONTAL);
        dump.setGravity(Gravity.CENTER_HORIZONTAL);
        dump.setLayoutParams(
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        for (int p = 0; p < 3; p++) {
          if (count < values.size()) {
            String state = values.get(count);
            CheckBox cb = new CheckBox(this);
            String id = mId + item.getId() + item.getName() + values.get(count);
            cb.setId(Funciones.str2int(id));
            cb.setChecked(reg.getBoolean("CHECK" + cb.getId()));
            cb.setText(state);

            checkBoxes.add(cb);
            dump.addView(cb);
            if (count == 0) comment = reg.getString("COMMENTCHECK" + cb.getId());
            count++;
            vistas.add(cb);
          }
        }
        checkboxLayout.addView(dump);
      }
      makeOnlyOneCheckable(checkBoxes);
      item.setCheckBoxes(checkBoxes);
      contenido.addView(checkboxLayout);
    } else if (type.equals("NUM")) {
      EditText e = new EditText(this);
      e.setBackgroundResource(R.drawable.fondo_edittext);
      e.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

      String id = mId + item.getId() + item.getName();
      e.setId(Funciones.str2int(id));
      e.setText(reg.getString("TEXT" + e.getId()));
      e.setLayoutParams(new LinearLayout.LayoutParams(100, ViewGroup.LayoutParams.WRAP_CONTENT));
      e.setGravity(Gravity.CENTER_HORIZONTAL);
      vistas.add(e);
      item.setVista(e);
      contenido.addView(e);

      comment = reg.getString("COMMENTTEXT" + e.getId());
    } else if (type.equals("VARCHAR")) {
      EditText e = new EditText(this);
      e.setBackgroundResource(R.drawable.fondo_edittext);
      e.setInputType(InputType.TYPE_CLASS_TEXT);
      e.setLines(2);
      e.setGravity(Gravity.LEFT | Gravity.TOP);

      String id = mId + item.getId() + item.getName();
      e.setId(Funciones.str2int(id));
      e.setText(reg.getString("TEXT" + e.getId()));
      vistas.add(e);
      item.setVista(e);
      contenido.addView(e);
      comment = reg.getString("COMMENTTEXT" + e.getId());
    }

    if (!item.getName().equals("COMENTARIOS")) {
      EditText comentario = new EditText(this);
      comentario.setLayoutParams(params);
      comentario.setBackgroundResource(R.drawable.fondo_edittext);
      comentario.setLines(3);
      comentario.setText(comment);
      comentario.setHint("Observaciones");
      item.setDescription(comentario);
      contenido.addView(comentario);
    }
    return contenido;
  }
コード例 #21
0
  public void addView(int type) {
    book_count++;
    act_count++;
    set_flag[book_count] = type;

    final EditText name, author, quantity, edition, isbn;
    ImageView cancel;
    RadioGroup radioGroup;
    Button plus_btn, minus_btn;
    RadioButton radio_new, radio_old;
    AwesomeTextView link;

    View v = LayoutInflater.from(context).inflate(R.layout.books_edittext, linearLayout, false);
    name = (EditText) v.findViewById(R.id.bookname_edittxt);
    isbn = (EditText) v.findViewById(R.id.isbn_edittxt);
    author = (EditText) v.findViewById(R.id.bookauthor_edittxt);
    cancel = (ImageView) v.findViewById(R.id.cancel_action);
    radioGroup = (RadioGroup) v.findViewById(R.id.radio_group);
    quantity = (EditText) v.findViewById(R.id.quantity_edittext);
    edition = (EditText) v.findViewById(R.id.bookedition_edittxt);
    plus_btn = (Button) v.findViewById(R.id.plus_button);
    minus_btn = (Button) v.findViewById(R.id.minus_button);
    radio_new = (RadioButton) v.findViewById(R.id.radio_btn_new);
    radio_old = (RadioButton) v.findViewById(R.id.radio_btn_old);
    link = (AwesomeTextView) v.findViewById(R.id.link_textview);

    link.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String url =
                "https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=isbn";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            v.getContext().startActivity(i);
          }
        });

    if (type == 1) {
      radioGroup.setVisibility(View.VISIBLE);
      link.setVisibility(View.VISIBLE);
    } else if (type == 2) {
      name.setHint("Stationary Title");
      author.setHint("Stationary Description");
      name.setInputType(
          InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
      edition.setVisibility(View.GONE);
      isbn.setVisibility(View.GONE);
    } else if (type == 3) {
      name.setHint("Description..");
      name.setInputType(
          InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
      author.setVisibility(View.GONE);
      edition.setVisibility(View.GONE);
      isbn.setVisibility(View.GONE);
    }

    v.setId(9000 + book_count);

    name.setId(1000 + book_count);
    author.setId(2000 + book_count);
    cancel.setId(3000 + book_count);
    quantity.setId(4000 + book_count);
    radio_new.setId(5000 + book_count);
    radio_old.setId(6000 + book_count);
    edition.setId(7000 + book_count);
    isbn.setId(8000 + book_count);

    name.requestFocus();

    cancel.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View vi) {

            int id = vi.getId();
            // Toast.makeText(context,"cancelled"+id,Toast.LENGTH_SHORT).show();
            View v = linearLayout.findViewById(id - 3000 + 9000);
            linearLayout.removeView(v);
            set_flag[id - 3000] = 0;
            act_count--;
          }
        });

    plus_btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (quantity.getText().toString().length() == 0) {
              quantity.setText("1");
              return;
            }
            int x = Integer.parseInt(quantity.getText().toString());
            x++;
            quantity.setText(x + "");
          }
        });

    minus_btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (quantity.getText().toString().length() == 0) {
              quantity.setText("1");
              return;
            }
            int x = Integer.parseInt(quantity.getText().toString());
            x--;
            if (x < 1) {
              quantity.setText("1");
              return;
            }
            quantity.setText(x + "");
          }
        });

    linearLayout.addView(v);
  }
コード例 #22
0
ファイル: BluetoothEx.java プロジェクト: soragami/frobo
  // アクティビティ起動時に呼ばれる
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // レイアウトの生成
    LinearLayout layout = new LinearLayout(this);
    layout.setBackgroundColor(Color.rgb(255, 255, 255));
    layout.setOrientation(LinearLayout.VERTICAL);
    setContentView(layout);

    // 送信エディットテキストの生成
    edtSend = new EditText(this);
    edtSend.setId(2);
    edtSend.setText("", TextView.BufferType.NORMAL);
    edtSend.setLayoutParams(new LinearLayout.LayoutParams(MP, WC));
    layout.addView(edtSend);

    LinearLayout button_l3 = new LinearLayout(this);
    button_l3.setBackgroundColor(Color.rgb(255, 200, 255));
    button_l3.setOrientation(LinearLayout.HORIZONTAL);
    button_l3.setLayoutParams(new LinearLayout.LayoutParams(WC, WC));
    layout.addView(button_l3);

    LinearLayout button_l2 = new LinearLayout(this);
    button_l2.setBackgroundColor(Color.rgb(200, 255, 200));
    button_l2.setOrientation(LinearLayout.HORIZONTAL);
    button_l2.setLayoutParams(new LinearLayout.LayoutParams(WC, WC));
    layout.addView(button_l2);

    LinearLayout button_l1 = new LinearLayout(this);
    button_l1.setBackgroundColor(Color.rgb(255, 200, 200));
    button_l1.setOrientation(LinearLayout.HORIZONTAL);
    button_l1.setLayoutParams(new LinearLayout.LayoutParams(WC, WC));
    layout.addView(button_l1);

    // 送信ボタンの生成
    btnSend = new Button(this);
    btnSend.setId(100);
    btnSend.setText("送信");
    btnSend.setOnClickListener(this);
    btnSend.setLayoutParams(new LinearLayout.LayoutParams(WC, WC));
    layout.addView(btnSend);

    B_7 = new Button(this);
    B_7.setId(70);
    B_7.setText("7");
    B_7.setOnClickListener(this);
    B_7.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l3.addView(B_7);

    B_8 = new Button(this);
    B_8.setId(80);
    B_8.setText("8");
    B_8.setOnClickListener(this);
    B_8.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l3.addView(B_8);

    B_9 = new Button(this);
    B_9.setId(90);
    B_9.setText("9");
    B_9.setOnClickListener(this);
    B_9.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l3.addView(B_9);

    B_4 = new Button(this);
    B_4.setId(40);
    B_4.setText("4");
    B_4.setOnClickListener(this);
    B_4.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l2.addView(B_4);

    B_5 = new Button(this);
    B_5.setId(50);
    B_5.setText("5");
    B_5.setOnClickListener(this);
    B_5.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l2.addView(B_5);

    B_6 = new Button(this);
    B_6.setId(60);
    B_6.setText("6");
    B_6.setOnClickListener(this);
    B_6.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l2.addView(B_6);

    B_1 = new Button(this);
    B_1.setId(10);
    B_1.setText("1");
    B_1.setOnClickListener(this);
    B_1.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l1.addView(B_1);

    B_2 = new Button(this);
    B_2.setId(20);
    B_2.setText("2");
    B_2.setOnClickListener(this);
    B_2.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l1.addView(B_2);

    B_3 = new Button(this);
    B_3.setId(30);
    B_3.setText("3");
    B_3.setOnClickListener(this);
    B_3.setLayoutParams(new LinearLayout.LayoutParams(70, 70));
    button_l1.addView(B_3);

    // 受信ラベルの生成
    lblReceive = new TextView(this);
    lblReceive.setId(1);
    lblReceive.setText("");
    lblReceive.setTextSize(16.0f);
    lblReceive.setTextColor(Color.rgb(0, 0, 0));
    lblReceive.setLayoutParams(new LinearLayout.LayoutParams(MP, WC));
    layout.addView(lblReceive);

    // Bluetoothアダプタ
    btAdapter = BluetoothAdapter.getDefaultAdapter();

    // チャットマネージャ
    chatManager = new ChatManager(handler);
  }