Java Code Examples for android.widget.EditText#setLayoutParams()

The following examples show how to use android.widget.EditText#setLayoutParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From journaldev with MIT License 6 votes vote down vote up
public void withEditText(View view) {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("With Edit Text");

        final EditText input = new EditText(MainActivity.this);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT);
        input.setLayoutParams(lp);
        builder.setView(input);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Toast.makeText(getApplicationContext(), "Text entered is " + input.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });
        builder.show();
    }
 
Example 2
Source File: GrxEqualizerManager.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 6 votes vote down vote up
private void showSaveProfileDialog(){
    final EditText editText = new EditText(mContext);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    layoutParams.setMarginStart(50);
    layoutParams.setMarginEnd(50);
    editText.setLayoutParams(layoutParams);
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle(R.string.eq_profile_save);
    builder.setMessage(R.string.eq_profile_name);

    builder.setView(editText);

    builder.setPositiveButton(android.R.string.ok, (dialogInterface, i)
            -> saveCurrentProfile(editText.getText().toString()));
    builder.create().show();
}
 
Example 3
Source File: BaseDialog.java    From TestChat with Apache License 2.0 6 votes vote down vote up
/**
 * 设置编辑列表VIEW
 *
 * @param names 编辑view 的name
 * @return this
 */
public BaseDialog setEditViewsName(List<String> names) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String name :
                names) {
                TextView textView = new TextView(getContext());
                textView.setText(name);
                EditText editText = new EditText(getContext());
                editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
                editText.setHint("请输入" + name);
                editText.setPadding(10, 0, 0, 0);
                editText.setHintTextColor(Color.BLUE);
                LinearLayout child = new LinearLayout(getContext());
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                child.setOrientation(LinearLayout.HORIZONTAL);
                child.setGravity(Gravity.CENTER_VERTICAL);
                child.setLayoutParams(params);
                child.addView(textView);
                child.addView(editText);
                middleLayout.addView(child);
        }
        return this;
}
 
Example 4
Source File: HyperTextEditor.java    From YCCustomText with Apache License 2.0 6 votes vote down vote up
/**
 * 添加生成文本输入框
 * @param hint								内容
 * @param paddingTop						到顶部高度
 * @return
 */
private EditText createEditText(String hint, int paddingTop) {
	EditText editText = new DeletableEditText(getContext());
	LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	editText.setLayoutParams(layoutParams);
	editText.setTextSize(16);
	editText.setTextColor(Color.parseColor("#616161"));
	editText.setCursorVisible(true);
	editText.setBackground(null);
	editText.setOnKeyListener(keyListener);
	editText.setOnFocusChangeListener(focusListener);
	editText.addTextChangedListener(textWatcher);
	editText.setTag(viewTagIndex++);
	editText.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
	editText.setHint(hint);
	editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
	editText.setTextColor(rtTextColor);
	editText.setHintTextColor(rtHintTextColor);
	editText.setLineSpacing(rtTextLineSpace, 1.0f);
	HyperLibUtils.setCursorDrawableColor(editText, cursorColor);
	return editText;
}
 
Example 5
Source File: KlyphPlacePickerFragment.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ViewGroup view = (ViewGroup) getView();
    if (showSearchBox) {
        ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_placepickerfragment_search_box_stub);
        if (stub != null) {
            View stubView = stub.inflate();
            
            searchBox = (EditText) stubView.findViewById(R.id.com_facebook_picker_search_text);

            // Put the list under the search box
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.MATCH_PARENT,
                    RelativeLayout.LayoutParams.MATCH_PARENT);
            layoutParams.addRule(RelativeLayout.BELOW, R.id.search_box);

            ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
            listView.setLayoutParams(layoutParams);

            // If we need to, put the search box under the title bar.
            if (view.findViewById(R.id.com_facebook_picker_title_bar) != null) {
                layoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.MATCH_PARENT,
                        RelativeLayout.LayoutParams.WRAP_CONTENT);
                layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);

                searchBox.setLayoutParams(layoutParams);
            }

            searchBox.addTextChangedListener(new SearchTextWatcher());
            if (!TextUtils.isEmpty(searchText)) {
                searchBox.setText(searchText);
            }
        }
    }
}
 
Example 6
Source File: ConfigureStandupTimer.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private View createMeetingLengthTextBox() {
    meetingLengthEditText = new EditText(this);
    meetingLengthEditText.setGravity(Gravity.CENTER);
    meetingLengthEditText.setKeyListener(new DigitsKeyListener());
    meetingLengthEditText.setRawInputType(InputType.TYPE_CLASS_PHONE);
    meetingLengthEditText.setLayoutParams(new LayoutParams(dipsToPixels(60), LayoutParams.WRAP_CONTENT));
    meetingLengthEditText.setText(Integer.toString(meetingLength));
    meetingLengthEditText.setLines(1);

    meetingLengthSpinner = null;
    return meetingLengthEditText;
}
 
Example 7
Source File: PatientIdElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {

    et = new EditText(c);
    et.setPadding(10, 5, 10, 5);
    et.setText(answer);
    et.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    et.setGravity(Gravity.CENTER_HORIZONTAL);
    et.setKeyListener(new DialerKeyListener());

    LinearLayout ll = new LinearLayout(c);
    ll.setOrientation(LinearLayout.VERTICAL);

    ll.addView(et, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));
    ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));

    //SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c);
    boolean barcodeEnable = true; //sp.getBoolean(Constants.PREFERENCE_BARCODE_ENABLED, false);

    if (barcodeEnable) {
        barcodeButton = new Button(c);
        barcodeButton.setText(c.getResources().getString(
                R.string.procedurerunner_scan_id));
        barcodeButton.setOnClickListener(this);
        barcodeButton.setGravity(Gravity.CENTER_HORIZONTAL);
        ll.addView(barcodeButton, new LinearLayout.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    }
    return encapsulateQuestion(c, ll);
}
 
Example 8
Source File: Pinview.java    From Pinview with MIT License 5 votes vote down vote up
public void setSplitWidth(int splitWidth) {
    this.mSplitWidth = splitWidth;
    int margin = splitWidth / 2;
    params.setMargins(margin, margin, margin, margin);

    for (EditText editText : editTextList) {
        editText.setLayoutParams(params);
    }
}
 
Example 9
Source File: Pinview.java    From Pinview with MIT License 5 votes vote down vote up
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
Example 10
Source File: SuperDialog.java    From SuperDialog with Apache License 2.0 5 votes vote down vote up
/**
 * 输入框
 */
private void initInputView(LinearLayout viewRoot) {
    inputView = new EditText(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(dp2px(15), dp2px(5), dp2px(15), dp2px(5));
    inputView.setLayoutParams(layoutParams);
    inputView.setTextColor(contentTextColor);
    inputView.setTextSize(contentTextSize);
    if (inputListener != null) {
        inputListener.onInitEditText(inputView);
    }
    viewRoot.addView(inputView);
}
 
Example 11
Source File: DialogUtil.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
/**
 * 显示编辑的Dialog提示框
 */
public static void showEditDialog(Context context, String title,
                                  String content, String contentHint, final OnEditListener listener) {

    int top = DisplayUtil.dip2px(context, 20f);
    int left = DisplayUtil.dip2px(context, 26f);

    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setLayoutParams(LayoutUtil.newFrameLayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    frameLayout.setPadding(left, top, left, 0);

    int padding = DisplayUtil.dip2px(context, 5);
    final EditText editText = new EditText(context);
    editText.setPadding(padding, padding, padding, padding);
    editText.setTextSize(15);
    editText.setText(content);
    editText.setLayoutParams(LayoutUtil.newViewGroupParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    editText.setSingleLine(true);
    editText.setFilters(new InputFilter[]{ new InputFilter.LengthFilter(10)});
    editText.setHint(contentHint);
    ViewUtil.setInputType(editText, com.sky.xposed.common.Constant.InputType.TEXT);
    frameLayout.addView(editText);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setView(frameLayout);
    builder.setPositiveButton("确定", (dialog, which) -> {
        // 返回文本的内容
        listener.onTextChange(editText, editText.getText().toString());
    });
    builder.setNegativeButton("取消", null);
    builder.show();
}
 
Example 12
Source File: RenameDialog.java    From Beedio with GNU General Public License v2.0 5 votes vote down vote up
protected RenameDialog(Context context, String hint) {
    this.context = context;
    text = new EditText(context);
    text.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    text.setHint(hint);
    dialog = new AlertDialog.Builder(context)
            .setView(text).setMessage("Type new name:")
            .setPositiveButton("OK", this)
            .setNegativeButton("CANCEL", this)
            .create();
    dialog.show();
}
 
Example 13
Source File: EditTextViewSample.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
@Override
public void createViews(Context context, ViewGroup layout) {
    EditText edit = new EditText(context);
    edit.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    edit.setText("Hello there!");
    PixateFreestyle.setStyleClass(edit, "myEditText");
    layout.addView(edit);

    addView(edit);
}
 
Example 14
Source File: EditSpInputView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
public EditSpInputView(Context context, SpBean spBean, int inputType) {
    this.spBean = spBean;
    editText = new EditText(context);
    editText.setText(spBean.value.toString());
    editText.setInputType(inputType | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    editText.setSelection(spBean.value.toString().length());
}
 
Example 15
Source File: BlacklistPageInflater.java    From k3pler with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void showEditDialog(final String item){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, android.R.style.Theme_DeviceDefault_Dialog);
    builder.setTitle(context.getString(R.string.edit_blaclist_item));
    final EditText editText = new EditText(context);
    editText.setText(item);
    editText.setInputType(InputType.TYPE_CLASS_TEXT);
    LinearLayout parentLayout = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(dpToPx(20), dpToPx(20), dpToPx(20), dpToPx(20));
    editText.setLayoutParams(layoutParams);
    parentLayout.addView(editText);
    builder.setView(parentLayout);
    builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String newAddr = editText.getText().toString();
            if(newAddr.length() > 3) {
                sqliteDBHelper = new SqliteDBHelper(context,
                        new SQLiteBL(context).getWritableDatabase(),
                        SQLiteBL.BLACKLIST_DATA, SQLiteBL.TABLE_NAME);
                sqliteDBHelper.update(item, newAddr);
                sqliteDBHelper.close();
                setBlacklistLstView();
            }
        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.getWindow().setType(new RequestDialog().getWindowType());
    alertDialog.show();
}
 
Example 16
Source File: EditPage.java    From ShareSDKShareDifMsgDemo-Android with MIT License 5 votes vote down vote up
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LinearLayout.LayoutParams lpMain = new LinearLayout.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());
	LinearLayout.LayoutParams lpContent = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// 文字输入区域
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(reqData.get("text")));
	etContent.addTextChangedListener(this);
	LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

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

	return llMainBody;
}
 
Example 17
Source File: AmountView.java    From AmmountView with Apache License 2.0 5 votes vote down vote up
public AmountView(Context context, AttributeSet attrs) {
    super(context, attrs);

    LayoutInflater.from(context).inflate(R.layout.view_amount, this);
    etAmount = (EditText) findViewById(R.id.etAmount);
    btnDecrease = (Button) findViewById(R.id.btnDecrease);
    btnIncrease = (Button) findViewById(R.id.btnIncrease);
    btnDecrease.setOnClickListener(this);
    btnIncrease.setOnClickListener(this);
    etAmount.addTextChangedListener(this);

    TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.AmountView);
    int btnWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnWidth, LayoutParams.WRAP_CONTENT);
    int tvWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvWidth, 80);
    int tvTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvTextSize, 0);
    int btnTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnTextSize, 0);
    obtainStyledAttributes.recycle();

    LayoutParams btnParams = new LayoutParams(btnWidth, LayoutParams.MATCH_PARENT);
    btnDecrease.setLayoutParams(btnParams);
    btnIncrease.setLayoutParams(btnParams);
    if (btnTextSize != 0) {
        btnDecrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
        btnIncrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
    }

    LayoutParams textParams = new LayoutParams(tvWidth, LayoutParams.MATCH_PARENT);
    etAmount.setLayoutParams(textParams);
    if (tvTextSize != 0) {
        etAmount.setTextSize(tvTextSize);
    }
}
 
Example 18
Source File: ReactChatInputManager.java    From aurora-imui with MIT License 4 votes vote down vote up
@ReactProp(name = "inputViewHeight")
public void setEditTextHeight(ChatInputView chatInputView, int height) {
    Log.i("React", "setting edit text height: " + height);
    EditText editText = chatInputView.getInputView();
    editText.setLayoutParams(new LinearLayout.LayoutParams(mWidth, height));
}
 
Example 19
Source File: PostFormActivity.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
private void setViews() {
    setContentView(settings.isPinnedMarkup() ? R.layout.postform_layout_pinned_markup : R.layout.postform_layout);
    nameLayout = findViewById(R.id.postform_name_email_layout);
    nameField = (EditText) findViewById(R.id.postform_name_field);
    emailField = (EditText) findViewById(R.id.postform_email_field);
    passwordLayout = findViewById(R.id.postform_password_layout);
    passwordField = (EditText) findViewById(R.id.postform_password_field);
    chkboxLayout = findViewById(R.id.postform_checkbox_layout);
    sageChkbox = (CheckBox) findViewById(R.id.postform_sage_checkbox);
    sageChkbox.setOnClickListener(this);
    custommarkChkbox = (CheckBox) findViewById(R.id.postform_custommark_checkbox);
    attachmentsLayout = (LinearLayout) findViewById(R.id.postform_attachments_layout);
    spinner = (Spinner) findViewById(R.id.postform_spinner);
    subjectField = (EditText) findViewById(R.id.postform_subject_field);
    commentField = (EditText) findViewById(R.id.postform_comment_field);
    markLayout = (LinearLayout) findViewById(R.id.postform_mark_layout);
    for (int i=0, len=markLayout.getChildCount(); i<len; ++i) markLayout.getChildAt(i).setOnClickListener(this);
    captchaLayout = findViewById(R.id.postform_captcha_layout);
    captchaView = (ImageView) findViewById(R.id.postform_captcha_view);
    captchaView.setOnClickListener(this);
    captchaView.setOnCreateContextMenuListener(this);
    captchaLoading = findViewById(R.id.postform_captcha_loading);
    captchaField = (EditText) findViewById(R.id.postform_captcha_field);
    captchaField.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                send();
                return true;
            }
            return false;
        }
    });
    sendButton = (Button) findViewById(R.id.postform_send_button);
    sendButton.setOnClickListener(this);
    
    if (settings.isHidePersonalData()) {
        nameLayout.setVisibility(View.GONE);
        passwordLayout.setVisibility(View.GONE);
    } else {
        nameLayout.setVisibility(boardModel.allowNames || boardModel.allowEmails ? View.VISIBLE : View.GONE);
        nameField.setVisibility(boardModel.allowNames ? View.VISIBLE : View.GONE);
        emailField.setVisibility(boardModel.allowEmails ? View.VISIBLE : View.GONE);
        passwordLayout.setVisibility((boardModel.allowDeletePosts || boardModel.allowDeleteFiles) ? View.VISIBLE : View.GONE);
        
        if (boardModel.allowNames && !boardModel.allowEmails) nameField.setLayoutParams(getWideLayoutParams());
        else if (!boardModel.allowNames && boardModel.allowEmails) emailField.setLayoutParams(getWideLayoutParams());
    }
    
    boolean[] markupEnabled = {
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_QUOTE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_BOLD),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_ITALIC),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_UNDERLINE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_STRIKE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_SPOILER),
    };
    if (markupEnabled[0] || markupEnabled[1] || markupEnabled[2] || markupEnabled[3] || markupEnabled[4] || markupEnabled[5]) {
        markLayout.setVisibility(View.VISIBLE);
        if (!markupEnabled[0]) markLayout.findViewById(R.id.postform_mark_quote).setVisibility(View.GONE);
        if (!markupEnabled[1]) markLayout.findViewById(R.id.postform_mark_bold).setVisibility(View.GONE);
        if (!markupEnabled[2]) markLayout.findViewById(R.id.postform_mark_italic).setVisibility(View.GONE);
        if (!markupEnabled[3]) markLayout.findViewById(R.id.postform_mark_underline).setVisibility(View.GONE);
        if (!markupEnabled[4]) markLayout.findViewById(R.id.postform_mark_strike).setVisibility(View.GONE);
        if (!markupEnabled[5]) markLayout.findViewById(R.id.postform_mark_spoiler).setVisibility(View.GONE);
    } else {
        markLayout.setVisibility(View.GONE);
    }
    
    subjectField.setVisibility(boardModel.allowSubjects ? View.VISIBLE : View.GONE);
    chkboxLayout.setVisibility(boardModel.allowSage || boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    sageChkbox.setVisibility(boardModel.allowSage ? View.VISIBLE : View.GONE);
    custommarkChkbox.setVisibility(boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    if (boardModel.customMarkDescription != null) custommarkChkbox.setText(boardModel.customMarkDescription);
    spinner.setVisibility(boardModel.allowIcons ? View.VISIBLE : View.GONE);
    
    if (boardModel.allowIcons) {
        spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, boardModel.iconDescriptions));
    }
}
 
Example 20
Source File: FragmentCharacteristicDetail.java    From EFRConnect-android with Apache License 2.0 4 votes vote down vote up
private void addValue(final Field field) {

        LinearLayout parentLayout = new LinearLayout(context);
        LinearLayout.LayoutParams parentParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        parentLayout.setOrientation(LinearLayout.VERTICAL);

        parentParams.setMargins(0, defaultMargin, 0, defaultMargin / 2);
        parentLayout.setLayoutParams(parentParams);

        LinearLayout valueLayout = addValueLayout();
        TextView fieldNameView = addValueFieldName(field.getName(), valueLayout.getId());
        fieldNameView.setGravity(Gravity.CENTER_VERTICAL);
        fieldNameView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_list_item_value_label_text_size));
        TextView fieldUnitView = addValueUnit(field);
        fieldUnitView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_list_item_value_label_text_size));
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = Gravity.BOTTOM;
        fieldUnitView.setLayoutParams(layoutParams);
        hidableViews.add(fieldUnitView);

        if (!parseProblem && field.getReference() == null) {
            String format = field.getFormat();
            String val = readNextValue(format);


            if (!(format.toLowerCase().equals("utf8s") || format.toLowerCase().equals("utf16s"))) {
                int decimalExponentAbs = (int) abs(field.getDecimalExponent());
                double divider = Math.pow(10, decimalExponentAbs);
                double valDouble = Double.parseDouble(val);
                double valTmp = valDouble / divider;
                val = Double.toString(valTmp);
            } else {
                writeString = true;
                val = val.replace("\0", "");
            }


            if (writeable || writeableWithoutResponse) {
                // inline field value
                EditText fieldValueEdit = addValueEdit(field, val);
                fieldValueEdit.setGravity(Gravity.CENTER_VERTICAL);
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f);
                params.setMargins(8, 0, 0, 0);
                params.gravity = Gravity.CENTER_VERTICAL;
                fieldValueEdit.setLayoutParams(params);
                fieldValueEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_list_item_value_text_size));
                editTexts.add(fieldValueEdit);
                TextView fieldValue = (TextView) addFieldName(fieldValueEdit.getText().toString());
                fieldValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_list_item_value_text_size));
                hidableViews.add(fieldValue);
                fieldValue.setTextColor(ContextCompat.getColor(getActivity(), R.color.silabs_primary_text));
                valueLayout.addView(fieldValue);

                // dialog field value
                // field name
                View fieldName = addFieldName(field.getName());
                params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f);
                params.setMargins(0, 0, 8, 0);
                params.gravity = Gravity.CENTER_VERTICAL;
                fieldName.setLayoutParams(params);
                // container for editable field value and field name
                LinearLayout fieldContainer = new LinearLayout(context);
                fieldContainer.setOrientation(LinearLayout.HORIZONTAL);
                params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                params.setMargins(0, 5, 0, 5);
                fieldContainer.setLayoutParams(params);
                fieldContainer.addView(fieldName);
                fieldContainer.addView(fieldValueEdit);
                fieldContainer.setPadding(0, FIELD_CONTAINER_PADDING_TOP, 0, FIELD_CONTAINER_PADDING_BOTTOM);
                writableFieldsContainer.addView(fieldContainer);
            } else {
                TextView fieldValueView = addValueText(val);
                fieldValueView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_list_item_value_text_size));
                hidableViews.add(fieldValueView);
                valueLayout.addView(fieldValueView);
            }

            updateSaveButtonState();
        }

        valueLayout.addView(fieldUnitView);
        parentLayout.addView(valueLayout);
        parentLayout.addView(fieldNameView);
        valuesLayout.addView(parentLayout);
    }