Exemple #1
1
  private void initViews() {
    body = (RelativeLayout) findViewById(R.id.body);
    loadingoverlay = (LoadingOverlay) findViewById(R.id.loadingoverlay);

    registerTV = (TextView) findViewById(R.id.registerTV);
    findpwdTV = (TextView) findViewById(R.id.findpwdTV);

    userNameET = (ExEditText) findViewById(R.id.userNameET);
    passwordET = (ExEditText) findViewById(R.id.passwordET);
    loginButton = (Button) findViewById(R.id.loginButton);

    EditText pwdinneret = passwordET.getEditText();
    int pl = pwdinneret.getPaddingLeft();
    pwdinneret.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    pwdinneret.setBackgroundDrawable(getResources().getDrawable(R.drawable.blue_input_bg));
    pwdinneret.setPadding(pl, 0, 0, 0); // 如果同时用,setPadding 将不会起作用,用的是
    // drawable里面自带的padding。setPadding要在setBackgroundDrawable之后执行才能生效
    pwdinneret.setFilters(new InputFilter[] {new InputFilter.LengthFilter(20)});

    EditText usernameinneret = userNameET.getEditText();
    pl = usernameinneret.getPaddingLeft();
    usernameinneret.setBackgroundDrawable(getResources().getDrawable(R.drawable.blue_input_bg));
    usernameinneret.setPadding(pl, 0, 0, 0);
    usernameinneret.setFilters(new InputFilter[] {new InputFilter.LengthFilter(20)});
  }
  protected void setLogic(Logic logic) {
    mLogic = logic;
    NumberKeyListener calculatorKeyListener =
        new NumberKeyListener() {
          public int getInputType() {
            return EditorInfo.TYPE_CLASS_TEXT;
          }

          @Override
          protected char[] getAcceptedChars() {
            return ACCEPTED_CHARS;
          }

          @Override
          public CharSequence filter(
              CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            /* the EditText should still accept letters (eg. 'sin')
               coming from the on-screen touch buttons, so don't filter anything.
            */
            return null;
          }
        };

    Editable.Factory factory = new CalculatorEditable.Factory(logic);
    for (int i = 0; i < 2; ++i) {
      EditText text = (EditText) getChildAt(i);
      text.setBackgroundDrawable(null);
      text.setEditableFactory(factory);
      text.setKeyListener(calculatorKeyListener);
      text.setSingleLine();
    }
  }
Exemple #3
0
  public StringWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mAnswer = new EditText(context);

    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    params.setMargins(7, 5, 7, 5);
    mAnswer.setLayoutParams(params);

    // capitalize the first letter of the sentence
    mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));

    // needed to make long read only text scroll
    mAnswer.setHorizontallyScrolling(false);
    mAnswer.setSingleLine(false);

    if (prompt != null) {
      mReadOnly = prompt.isReadOnly();
      String s = prompt.getAnswerText();
      if (s != null) {
        mAnswer.setText(s);
      }

      if (mReadOnly) {
        mAnswer.setBackgroundDrawable(null);
        mAnswer.setFocusable(false);
        mAnswer.setClickable(false);
      }
    }

    addView(mAnswer);
  }
  /** 사용자 정보를 layout에 그려준다. */
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    View view = inflate(getContext(), R.layout.kakao_profile_layout, this);

    profile = (NetworkImageView) view.findViewById(R.id.com_kakao_profile_image);
    if (profileImageURL != null) setProfileURL(profileImageURL);
    if (!editable) {
      ImageView editableMark = (ImageView) view.findViewById(R.id.profile_edit);
      editableMark.setVisibility(View.INVISIBLE);
    }

    nicknameText = (EditText) view.findViewById(R.id.com_kakao_profile_nickname);
    if (!editable) {
      nicknameText.setEnabled(false);
      nicknameText.setKeyListener(null);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        nicknameText.setBackground(null);
      } else {
        nicknameText.setBackgroundDrawable(null);
      }
      nicknameText.setPadding(0, 0, 0, 0);
      nicknameText.setTextColor(getResources().getColor(R.color.com_kakao_profile_text));
    }
    if (nickname != null) nicknameText.setText(nickname);

    userIdText = (TextView) view.findViewById(R.id.com_kakao_profile_userId);
    if (userId != null) userIdText.setText(userId);
  }
  private LinearLayout getMainBody() {
    LinearLayout llMainBody = new LinearLayout(getContext());
    llMainBody.setOrientation(LinearLayout.VERTICAL);
    LayoutParams lpMain = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpMain.weight = 1;
    int dp_4 = dipToPx(getContext(), 4);
    lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
    llMainBody.setLayoutParams(lpMain);

    LinearLayout llContent = new LinearLayout(getContext());
    LayoutParams lpContent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpContent.weight = 1;
    llMainBody.addView(llContent, lpContent);

    // share content editor
    etContent = new EditText(getContext());
    etContent.setGravity(Gravity.LEFT | Gravity.TOP);
    etContent.setBackgroundDrawable(null);
    etContent.setText(String.valueOf(shareParamMap.get("text")));
    etContent.addTextChangedListener(this);
    LayoutParams lpEt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpEt.weight = 1;
    etContent.setLayoutParams(lpEt);
    llContent.addView(etContent);

    llContent.addView(getThumbView());
    llMainBody.addView(getBodyBottom());

    return llMainBody;
  }
  private void updateTextOnLayout(View view) {

    textHousenumber.setBackgroundDrawable(localizer.getDrawable("house_number_background"));

    inputNotes.setHint(localizer.getString("keypad_info_hint"));
    inputNotes.setBackgroundDrawable(
        localizer.get9PatchDrawable("textfield_multiline_activated_holo_dark"));

    view.findViewById(R.id.helpBtn).setBackgroundDrawable(localizer.getDrawable("icon_help"));

    View delimiter1 = view.findViewById(R.id.delimiter1);
    if (delimiter1 != null) {
      delimiter1.setBackgroundDrawable(localizer.getDrawable("icon_line_menu"));
    }
    View delimiter2 = view.findViewById(R.id.delimiter2);
    if (delimiter2 != null) {
      delimiter2.setBackgroundDrawable(localizer.getDrawable("icon_line_menu"));
    }

    ((Button) view.findViewById(R.id.button1)).setText(localizer.getString("button1"));

    ((Button) view.findViewById(R.id.button1)).setText(localizer.getString("button1"));
    ((Button) view.findViewById(R.id.button2)).setText(localizer.getString("button2"));
    ((Button) view.findViewById(R.id.button3)).setText(localizer.getString("button3"));
    ((Button) view.findViewById(R.id.button4)).setText(localizer.getString("button4"));
    ((Button) view.findViewById(R.id.button5)).setText(localizer.getString("button5"));
    ((Button) view.findViewById(R.id.button6)).setText(localizer.getString("button6"));
    ((Button) view.findViewById(R.id.button7)).setText(localizer.getString("button7"));
    ((Button) view.findViewById(R.id.button8)).setText(localizer.getString("button8"));
    ((Button) view.findViewById(R.id.button9)).setText(localizer.getString("button9"));
    ((Button) view.findViewById(R.id.button0)).setText(localizer.getString("button0"));

    ((Button) view.findViewById(R.id.buttonA)).setText(localizer.getString("buttonA"));
    ((Button) view.findViewById(R.id.buttonB)).setText(localizer.getString("buttonB"));
    ((Button) view.findViewById(R.id.buttonC)).setText(localizer.getString("buttonC"));
    ((Button) view.findViewById(R.id.buttonD)).setText(localizer.getString("buttonD"));
    ((Button) view.findViewById(R.id.buttonE)).setText(localizer.getString("buttonE"));
    ((Button) view.findViewById(R.id.buttonF)).setText(localizer.getString("buttonF"));

    ((Button) view.findViewById(R.id.buttonG)).setText(localizer.getString("buttonG"));
    ((Button) view.findViewById(R.id.buttonH)).setText(localizer.getString("buttonH"));
    ((Button) view.findViewById(R.id.buttonI)).setText(localizer.getString("buttonI"));

    ((Button) view.findViewById(R.id.buttonJ)).setText(localizer.getString("buttonJ"));
    ((Button) view.findViewById(R.id.buttonK)).setText(localizer.getString("buttonK"));
    ((Button) view.findViewById(R.id.buttonL)).setText(localizer.getString("buttonL"));

    ((Button) view.findViewById(R.id.buttonSep1)).setText(localizer.getString("buttonSep1"));
    ((Button) view.findViewById(R.id.buttonSep2)).setText(localizer.getString("buttonSep2"));
    ((Button) view.findViewById(R.id.buttonSep3)).setText(localizer.getString("buttonSep3"));

    initLettersRows(view);
  }
  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);
  }
 public void setMiddleViewImage(Drawable middleViewImage) {
   middleView.setBackgroundDrawable(middleViewImage);
 }
 public void setBackgroundDrawable(Drawable background) {
   super.setBackgroundDrawable(background);
   if (this.mBackgroundTintHelper != null) {
     this.mBackgroundTintHelper.onSetBackgroundDrawable(background);
   }
 }
  private void initComponents() {
    LinearLayout llRoot = (LinearLayout) this.findViewById(R.id.llRoot);
    LinearLayout llHeaderBase = (LinearLayout) this.findViewById(R.id.llHeaderBase);

    LinearLayout llHeaderUserSelector = (LinearLayout) this.findViewById(R.id.llHeaderUserSelector);
    EditText etFilterName = (EditText) this.findViewById(R.id.etFilterName);
    Button btnSearch = (Button) findViewById(R.id.btnSearch);
    btnFollowing = (Button) findViewById(R.id.btnFollowing);
    btnRecentContact = (Button) findViewById(R.id.btnRecentContact);
    lvUser = (ListView) this.findViewById(R.id.lvUser);

    LinearLayout llToolbar = (LinearLayout) this.findViewById(R.id.llToolbar);
    Button btnConfirm = (Button) this.findViewById(R.id.btnConfirm);
    Button btnCancel = (Button) this.findViewById(R.id.btnCancel);

    ThemeUtil.setRootBackground(llRoot);
    ThemeUtil.setSecondaryHeader(llHeaderBase);

    llHeaderUserSelector.setBackgroundDrawable(theme.getDrawable("bg_header_corner_search"));
    int padding6 = theme.dip2px(6);
    int padding8 = theme.dip2px(8);
    llHeaderUserSelector.setPadding(padding6, padding8, padding6, padding8);
    etFilterName.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half"));
    btnSearch.setBackgroundDrawable(theme.getDrawable("selector_btn_search"));
    btnFollowing.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_left"));
    btnFollowing.setPadding(0, 0, 0, 0);
    ColorStateList selectorBtnTab = theme.getColorStateList("selector_btn_tab");
    btnFollowing.setTextColor(selectorBtnTab);
    btnFollowing.setGravity(Gravity.CENTER);
    btnRecentContact.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_right"));
    btnRecentContact.setPadding(0, 0, 0, 0);
    btnRecentContact.setTextColor(selectorBtnTab);
    btnRecentContact.setGravity(Gravity.CENTER);

    ThemeUtil.setListViewStyle(lvUser);
    llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
    ThemeUtil.setBtnActionPositive(btnConfirm);
    ThemeUtil.setBtnActionNegative(btnCancel);

    TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
    tvTitle.setText(title);

    selectorAdapter = new UserQuickSelectorListAdapter(this, account, selectMode);
    showLoadingFooter();
    lvUser.setAdapter(selectorAdapter);
    lvUser.setFastScrollEnabled(yibo.isSliderEnabled());
    setBack2Top(lvUser);

    recyclerListener = new UserSelectorRecyclerListener();
    lvUser.setRecyclerListener(recyclerListener);

    lvUser.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == parent.getCount() - 1) {
              view.performClick();
            } else {
              CheckBox checkBox = (CheckBox) view.findViewById(R.id.cbUser);
              checkBox.performClick();
              UserQuickSelectorActivity.this.updateButtonState();
            }
          }
        });
  }