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

The following examples show how to use android.widget.EditText#setBackgroundColor() . 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: CodeLineCellFactory.java    From DebugRank with Apache License 2.0 6 votes vote down vote up
@Override
public View createCellEditor(GridPanel gridPanel, GridCellRange cellRange, Rect bounds)
{
    EditText editText = (EditText) super.createCellEditor(gridPanel, cellRange, bounds);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
        editText.setBackground(null);
    }

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
        editText.setBackgroundTintMode(PorterDuff.Mode.CLEAR);
    }

    editText.setBackgroundColor(ContextCompat.getColor(flexGrid.getContext(), R.color.colorTransparent));

    return editText;
}
 
Example 2
Source File: GeocodingBaseActivity.java    From mobile-android-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    inputField = new EditText(this);
    inputField.setTextColor(Color.WHITE);
    inputField.setBackgroundColor(Colors.DARK_TRANSPARENT_GRAY);
    inputField.setHint("Type address...");
    inputField.setHintTextColor(Color.LTGRAY);
    inputField.setSingleLine();
    inputField.setImeOptions(EditorInfo.IME_ACTION_DONE);

    int totalWidth = getResources().getDisplayMetrics().widthPixels;
    int padding = (int)(5 * getResources().getDisplayMetrics().density);

    int width = totalWidth - 2 * padding;
    int height = (int)(45 * getResources().getDisplayMetrics().density);

    RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(width, height);
    parameters.setMargins(padding, padding, 0, 0);
    addContentView(inputField, parameters);

    resultTable = new ListView(this);
    resultTable.setBackgroundColor(Colors.LIGHT_TRANSPARENT_GRAY);

    height = (int)(200 * getResources().getDisplayMetrics().density);

    parameters = new RelativeLayout.LayoutParams(width, height);
    parameters.setMargins(padding, 2 * padding + inputField.getLayoutParams().height, 0, 0);

    addContentView(resultTable, parameters);

    adapter = new GeocodingResultAdapter(this);
    adapter.width = width;
    resultTable.setAdapter(adapter);

    hideTable();
}
 
Example 3
Source File: TagFlowLayout.java    From support with Apache License 2.0 5 votes vote down vote up
public TagFlowLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    mInputView = new EditText(context);
    mInputView.setBackgroundColor(Color.TRANSPARENT);
    mInputView.addTextChangedListener(this);
    mInputView.setOnKeyListener(this);
    mInputView.setPadding(0, 0, 0, 0);
    mInputView.setMinWidth(20);
    mInputView.setSingleLine();
    mInputView.setGravity(Gravity.CENTER_VERTICAL);
    setDecorator(new SimpleDecorator(context));
    addView(mInputView);
    setOnClickListener(this);
    previewInEditMode();
}
 
Example 4
Source File: OEditTextField.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
public void initControl() {
    // Creating control
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    removeAllViews();
    setOrientation(VERTICAL);
    if (mEditable) {
        edtText = new EditText(mContext);
        edtText.setTypeface(OControlHelper.lightFont());
        edtText.setLayoutParams(params);
        edtText.setBackgroundColor(Color.TRANSPARENT);
        edtText.setPadding(0, 10, 10, 10);
        edtText.setHint(getLabel());
        edtText.setOnFocusChangeListener(this);
        if (textSize > -1) {
            edtText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            edtText.setTextAppearance(mContext, appearance);
        }
        edtText.setTextColor(textColor);
        addView(edtText);
    } else {
        txvText = new TextView(mContext);
        txvText.setTypeface(OControlHelper.lightFont());
        txvText.setLayoutParams(params);
        txvText.setBackgroundColor(Color.TRANSPARENT);
        txvText.setPadding(0, 10, 10, 10);
        if (textSize > -1) {
            txvText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            txvText.setTextAppearance(mContext, appearance);
        }
        txvText.setTextColor(textColor);
        addView(txvText);
    }
}
 
Example 5
Source File: OEditTextField.java    From framework with GNU Affero General Public License v3.0 5 votes vote down vote up
public void initControl() {
    // Creating control
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    removeAllViews();
    setOrientation(VERTICAL);
    if (mEditable) {
        edtText = new EditText(mContext);
        edtText.setTypeface(OControlHelper.lightFont());
        edtText.setLayoutParams(params);
        edtText.setBackgroundColor(Color.TRANSPARENT);
        edtText.setPadding(0, 10, 10, 10);
        edtText.setHint(getLabel());
        edtText.setOnFocusChangeListener(this);
        if (textSize > -1) {
            edtText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            edtText.setTextAppearance(mContext, appearance);
        }
        edtText.setTextColor(textColor);
        addView(edtText);
    } else {
        txvText = new TextView(mContext);
        txvText.setTypeface(OControlHelper.lightFont());
        txvText.setLayoutParams(params);
        txvText.setBackgroundColor(Color.TRANSPARENT);
        txvText.setPadding(0, 10, 10, 10);
        if (textSize > -1) {
            txvText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            txvText.setTextAppearance(mContext, appearance);
        }
        txvText.setTextColor(textColor);
        addView(txvText);
    }
}
 
Example 6
Source File: LyricsViewFragment.java    From QuickLyric with GNU General Public License v3.0 5 votes vote down vote up
private void exitEditTagsMode() {
    ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).setImageResource(R.drawable.ic_done_anim);
    Drawable editIcon = ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).getDrawable();
    ((Animatable) editIcon).start();

    if (getActivity().getCurrentFocus() != null) {
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isAcceptingText())
            imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
    }

    EditText songTV = getActivity().findViewById(R.id.song);
    EditText artistTV = getActivity().findViewById(R.id.artist);
    EditText newLyrics = getActivity().findViewById(R.id.edit_lyrics);

    songTV.setInputType(InputType.TYPE_NULL);
    artistTV.setInputType(InputType.TYPE_NULL);
    songTV.setBackgroundColor(Color.TRANSPARENT);
    artistTV.setBackgroundColor(Color.TRANSPARENT);

    String txt = mLrcThread == null ? null : mLyrics.getText();
    if (txt == null)
        txt = "";

    File musicFile = Id3Reader.getFile(getActivity(), mLyrics.getOriginalArtist(), mLyrics.getOriginalTitle(), true);

    if (!mLyrics.getArtist().equals(artistTV.getText().toString())
            || !mLyrics.getTitle().equals(songTV.getText().toString())
            || !Html.fromHtml(txt).toString().equals(newLyrics.getText().toString())) {
        mLyrics.setArtist(artistTV.getText().toString());
        mLyrics.setTitle(songTV.getText().toString());
        mLyrics.setText(newLyrics.getText().toString().replaceAll("\n", "<br/>"));
        if (PermissionsChecker.requestPermission(getActivity(),
                "android.permission.WRITE_EXTERNAL_STORAGE", 0, Id3Writer.REQUEST_CODE))
            new Id3Writer(this).execute(mLyrics, musicFile);
    } else
        new Id3Writer(this).onPreExecute();
    update(mLyrics, getView(), false);
}
 
Example 7
Source File: GameSelectionActivity.java    From AndroidPokerPlayer with MIT License 5 votes vote down vote up
private void setServerFieldBGColor(){
    EditText serverText = (EditText) findViewById(R.id.txt_server_name);
    int color = this.getResources().getColor(R.color.SpringGreen);
    if(!validServer){
        color = this.getResources().getColor(R.color.PaleVioletRed);
    }
    serverText.setBackgroundColor(color);
}
 
Example 8
Source File: EditFragment.java    From pandora with Apache License 2.0 4 votes vote down vote up
@Override
protected View getLayoutView() {
    View wrapper;
    editText = new EditText(getContext());
    int padding = ViewKnife.dip2px(16);
    editText.setPadding(padding, padding, padding, padding);
    editText.setBackgroundColor(Color.WHITE);
    editText.setGravity(Gravity.START | Gravity.TOP);
    editText.setTextColor(ViewKnife.getColor(R.color.pd_label_dark));
    editText.setLineSpacing(0, 1.2f);

    String[] options = getArguments().getStringArray(PARAM3);
    if (options != null && options.length > 0) {
        LinearLayout layout = new LinearLayout(getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        wrapper = layout;
        RecyclerView recyclerView = new RecyclerView(getContext());
        recyclerView.setBackgroundColor(Color.WHITE);
        LinearLayoutManager manager = new LinearLayoutManager(getContext());
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(manager);
        UniversalAdapter adapter = new UniversalAdapter();
        recyclerView.setAdapter(adapter);
        adapter.setListener(new UniversalAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, BaseItem item) {
                notifyResult(((OptionItem)item).data);
            }
        });
        List<BaseItem> items = new ArrayList<>(options.length);
        for (String option : options) {
            items.add(new OptionItem(option));
        }
        adapter.setItems(items);

        LinearLayout.LayoutParams recyclerParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewKnife.dip2px(50)
        );
        layout.addView(recyclerView, recyclerParam);
        LinearLayout.LayoutParams editParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
        );
        layout.addView(editText, editParam);
    } else {
        wrapper = editText;
    }
    return wrapper;
}
 
Example 9
Source File: HostInputDialog.java    From NetCloud_android with GNU General Public License v2.0 4 votes vote down vote up
public void show(int inputType){
    if(mHostInputDialog != null){
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    LinearLayout cnt = new LinearLayout(mContext);
    cnt.setBackgroundResource(R.drawable.list_item_bg);
    cnt.setOrientation(LinearLayout.VERTICAL);
    cnt.setGravity(Gravity.CENTER_HORIZONTAL);
    int vp = ScreenUtils.dp2px(12);
    int hp = (int) ResTools.getDimen(R.dimen.hor_padding);
    cnt.setPadding(hp, vp, hp, vp);

    final EditText editText = new EditText(mContext);
    editText.setBackgroundColor(ResTools.getColor(R.color.background));
    editText.setMaxLines(1);
    editText.setSingleLine();
    if(mOriginContent != null){
        editText.setText(mOriginContent);
    }
    editText.setFilters(new InputFilter[] {new InputFilter.LengthFilter(60)});
    InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

    if(inputType > 0){
        editText.setInputType(inputType);
    }

    cnt.addView(editText);

    TextView ok = new TextView(mContext);
    ok.setText(R.string.add);
    ok.setGravity(Gravity.CENTER);
    ok.setBackgroundResource(R.drawable.button_blue);
    ok.setTextColor(ResTools.getColor(R.color.blue));
    ok.setTextSize(TypedValue.COMPLEX_UNIT_PX, (int)ResTools.getDimen(R.dimen.textsize1));
    ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String host = editText.getText().toString();
            mCallback.onHostInput(host);
        }
    });

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ScreenUtils.dp2px(80), ScreenUtils.dp2px(32));
    lp.gravity = Gravity.CENTER_HORIZONTAL;
    lp.topMargin = ScreenUtils.dp2px(16);
    cnt.addView(ok, lp);

    builder.setView(cnt);

    mHostInputDialog = builder.create();
    mHostInputDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mHostInputDialog = null;
            mCallback.onDismiss();
        }
    });

    mHostInputDialog.show();
    editText.requestFocus();
}