In the page there is a page that receives from the database variables, which indicate which View elements should be created programmatically, through code. On phones with Android versions from 6.0, you can write data to all EditText , but you cannot enter data on Android 5.1.

To be more precise, EditText looks as if setEnabled(false) specified, but the element is focused and also allows to write data to it, but does not display it. If using the back button to return to the previous window, the elements are shown in EditText .

If you need to add anything to the question, please write as I just have no idea how to show this process.

On gifke tried to show the problem

problem

In this function, I check the parameters in inputParams and looking at the flags that are specified in them, I create elements and add them to the layout.

 private void buildForm(View parent, List<PaymentParams> inputParams) { Collections.sort(inputParamses); int edit_text_padding = (int) getActivity().getResources().getDimension(R.dimen.editTx_padding); //Adding input forms LinearLayout form = parent.findViewById(R.id.inputParamsContainer); form.removeAllViewsInLayout(); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, dpToPx(10), 0, dpToPx(10)); RelativeLayout.LayoutParams relparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); relparams.setMargins(0, dpToPx(10), 0, dpToPx(10)); for (PaymentParams params : inputParamses) { if (params.getParamType().equalsIgnoreCase("T") || params.getParamType().equalsIgnoreCase("N") || params.getParamType().equalsIgnoreCase("F") || params.getParamType().equalsIgnoreCase("I")) { LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); MyTextView textView = new MyTextView(getActivity()); textView.setHint(params.getName()); textView.setLayoutParams(layoutParams); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_12sp)); textView.setTextColor(getResources().getColor(R.color.colorDark)); textView.setGravity(Gravity.LEFT); textView.setText(params.getName()); linearLayout.addView(textView); textView.setVisibility(View.VISIBLE); final MaskEditText editText = new MaskEditText(getActivity()); // set inputType of EditText if (params.getParamType().equals("T")) editText.setInputType(InputType.TYPE_CLASS_TEXT); if (params.getParamType().equals("N")) editText.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getParamType().equals("F")) editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); if (params.getParamType().equals("I")) editText.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getIsReadOnly().equals("Y")) editText.setEnabled(false); editText.setHint(params.getHint()); editText.setLayoutParams(layoutParams); editText.setHintTextColor(getResources().getColor(R.color.colorDark)); editText.setPadding(edit_text_padding, edit_text_padding, edit_text_padding, edit_text_padding); editText.setBackground(getResources().getDrawable(R.drawable.edit_text_box)); editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_14sp)); editText.setTextColor(getResources().getColor(R.color.colorDark)); editText.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); if (params.getCode().equals("CARD_TRANSFER")) { cardNumber = editText; cardNumber.setMask("#### #### #### ####"); cardNumber.setSelection(cardNumber.getText().length()); cardNumber.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(final Editable s) { final String text = s.toString().replace(" ", ""); if (text.length() == 16) { // CHECK USER CARD ON DB } else { aboutUser.setVisibility(View.GONE); } } }); aboutUser = new MyTextView(getActivity()); aboutUser.setHint(params.getName()); aboutUser.setLayoutParams(layoutParams); aboutUser.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_14sp)); aboutUser.setTextColor(getResources().getColor(R.color.colorGrey)); aboutUser.setGravity(Gravity.LEFT); aboutUser.setText(""); linearLayout.addView(aboutUser); aboutUser.setVisibility(View.GONE); } if (params.getPaymentDetailCode().equals("CELL_PHONE") || params.getCode().equals("TELEPHONE")) { if (phoneNumber != null) linearLayout.removeView(phoneNumber); phoneNumber = editText; phoneNumber.setMaxLength(16); phoneNumber.setSelection(phoneNumber.getText().length()); phoneNumber.setMask("###### ### ## ##"); phoneNumber.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_form_phone, 0, 0, 0); phoneNumber.setCompoundDrawablePadding(25); } if (params.getCode().equals("SUM")) { RelativeLayout relativeLayout = new RelativeLayout(getActivity()); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); amountEdit = new MaskEditText(getActivity()); if (params.getParamType().equals("T")) amountEdit.setInputType(InputType.TYPE_CLASS_TEXT); if (params.getParamType().equals("N")) amountEdit.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getParamType().equals("F")) amountEdit.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); if (params.getParamType().equals("I")) amountEdit.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getIsReadOnly().equals("Y")) amountEdit.setEnabled(false); amountEdit.setHint(params.getHint()); amountEdit.setBackground(getResources().getDrawable(R.drawable.edit_text_box)); amountEdit.setLayoutParams(relparams); amountEdit.setHintTextColor(getResources().getColor(R.color.colorDark)); amountEdit.setPadding(edit_text_padding, edit_text_padding, edit_text_padding, edit_text_padding); amountEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_14sp)); amountEdit.setTextColor(getResources().getColor(R.color.colorDark)); amountEdit.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); amountEdit.addTextChangedListener(onTextAmountChangedListener()); amountEdit.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_form_payment, 0, 0, 0); amountEdit.setCompoundDrawablePadding(((int) getResources().getDimension(R.dimen.editTx_padding))); amountEdit.setTag(params.getCode()); if (params.getDefValue().length() > 0 && !params.getDefValue().equals("0")) amountEdit.setText(params.getDefValue()); relativeLayout.addView(amountEdit); linearLayout.addView(relativeLayout); } else { editText.setTag(params.getCode()); if (params.getDefValue().length() > 0 && !params.getDefValue().equals("0")) editText.setText(params.getDefValue()); linearLayout.addView(editText); } if (!params.getIsVisible().equals("Y")) linearLayout.setVisibility(View.GONE); form.addView(linearLayout); } else if (params.getParamType().equalsIgnoreCase("S")) { Spinner spinner = new Spinner(getActivity()); spinner.setLayoutParams(layoutParams); spinner.setPadding(dpToPx(10), dpToPx(10), dpToPx(10), dpToPx(10)); spinner.setTag(params.getCode()); String empty_string; MobileDBHelper dbHelper = new MobileDBHelper(getActivity().getBaseContext()); refParamList = new ArrayList<>(); try { refParamList = dbHelper.getRefParamList(params.getRefCode(), null); } catch (SQLException e) { e.printStackTrace(); } spinnerList = new ArrayList<>(); for (int i = 0; i < refParamList.size(); i++) { CodeAndName codeAndName = new CodeAndName(); codeAndName.setCode(refParamList.get(i).getCode()); codeAndName.setName(refParamList.get(i).getName()); spinnerList.add(codeAndName); } if (params.getRefCode().trim().length() == 0) { EmptyCodeAndNameAdapter codeAndNameAdapter = new EmptyCodeAndNameAdapter(getActivity(), android.R.layout.simple_spinner_item, spinnerList); spinner.setAdapter(codeAndNameAdapter); } else { CodeAndNameAdapter adapter = new CodeAndNameAdapter(getActivity(), android.R.layout.simple_spinner_item, spinnerList); spinner.setAdapter(adapter); } if (params.getCode().equals("SECTOR")) { spinner.setOnItemSelectedListener(sectorListener); } else { spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (((CodeAndName) parent.getAdapter().getItem(position)).getCode().equals("empty")) { TextView selectedText = (TextView) parent.getChildAt(0); if (selectedText != null) { selectedText.setTextColor(Color.RED); } } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } if (!params.getIsVisible().equals("Y")) spinner.setVisibility(View.GONE); form.addView(spinner); if (params.getIsReadOnly().equals("Y")) spinner.setEnabled(false); if (params.getDefValue().length() > 0) { for (int index = 0; index < spinnerList.size(); index++) { if (spinnerList.get(index).getCode().equals(params.getDefValue())) { spinner.setSelection(index); break; } } } } } Button submit = parent.findViewById(R.id.btnMakePayment); submit.setAllCaps(false); submit.setOnClickListener(this); } "T") || params.getParamType (). equalsIgnoreCase ( "N") || params.getParamType (). equalsIgnoreCase ( "F") || params.getParamType (). private void buildForm(View parent, List<PaymentParams> inputParams) { Collections.sort(inputParamses); int edit_text_padding = (int) getActivity().getResources().getDimension(R.dimen.editTx_padding); //Adding input forms LinearLayout form = parent.findViewById(R.id.inputParamsContainer); form.removeAllViewsInLayout(); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, dpToPx(10), 0, dpToPx(10)); RelativeLayout.LayoutParams relparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); relparams.setMargins(0, dpToPx(10), 0, dpToPx(10)); for (PaymentParams params : inputParamses) { if (params.getParamType().equalsIgnoreCase("T") || params.getParamType().equalsIgnoreCase("N") || params.getParamType().equalsIgnoreCase("F") || params.getParamType().equalsIgnoreCase("I")) { LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); MyTextView textView = new MyTextView(getActivity()); textView.setHint(params.getName()); textView.setLayoutParams(layoutParams); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_12sp)); textView.setTextColor(getResources().getColor(R.color.colorDark)); textView.setGravity(Gravity.LEFT); textView.setText(params.getName()); linearLayout.addView(textView); textView.setVisibility(View.VISIBLE); final MaskEditText editText = new MaskEditText(getActivity()); // set inputType of EditText if (params.getParamType().equals("T")) editText.setInputType(InputType.TYPE_CLASS_TEXT); if (params.getParamType().equals("N")) editText.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getParamType().equals("F")) editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); if (params.getParamType().equals("I")) editText.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getIsReadOnly().equals("Y")) editText.setEnabled(false); editText.setHint(params.getHint()); editText.setLayoutParams(layoutParams); editText.setHintTextColor(getResources().getColor(R.color.colorDark)); editText.setPadding(edit_text_padding, edit_text_padding, edit_text_padding, edit_text_padding); editText.setBackground(getResources().getDrawable(R.drawable.edit_text_box)); editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_14sp)); editText.setTextColor(getResources().getColor(R.color.colorDark)); editText.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); if (params.getCode().equals("CARD_TRANSFER")) { cardNumber = editText; cardNumber.setMask("#### #### #### ####"); cardNumber.setSelection(cardNumber.getText().length()); cardNumber.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(final Editable s) { final String text = s.toString().replace(" ", ""); if (text.length() == 16) { // CHECK USER CARD ON DB } else { aboutUser.setVisibility(View.GONE); } } }); aboutUser = new MyTextView(getActivity()); aboutUser.setHint(params.getName()); aboutUser.setLayoutParams(layoutParams); aboutUser.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_14sp)); aboutUser.setTextColor(getResources().getColor(R.color.colorGrey)); aboutUser.setGravity(Gravity.LEFT); aboutUser.setText(""); linearLayout.addView(aboutUser); aboutUser.setVisibility(View.GONE); } if (params.getPaymentDetailCode().equals("CELL_PHONE") || params.getCode().equals("TELEPHONE")) { if (phoneNumber != null) linearLayout.removeView(phoneNumber); phoneNumber = editText; phoneNumber.setMaxLength(16); phoneNumber.setSelection(phoneNumber.getText().length()); phoneNumber.setMask("###### ### ## ##"); phoneNumber.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_form_phone, 0, 0, 0); phoneNumber.setCompoundDrawablePadding(25); } if (params.getCode().equals("SUM")) { RelativeLayout relativeLayout = new RelativeLayout(getActivity()); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); amountEdit = new MaskEditText(getActivity()); if (params.getParamType().equals("T")) amountEdit.setInputType(InputType.TYPE_CLASS_TEXT); if (params.getParamType().equals("N")) amountEdit.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getParamType().equals("F")) amountEdit.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); if (params.getParamType().equals("I")) amountEdit.setInputType(InputType.TYPE_CLASS_NUMBER); if (params.getIsReadOnly().equals("Y")) amountEdit.setEnabled(false); amountEdit.setHint(params.getHint()); amountEdit.setBackground(getResources().getDrawable(R.drawable.edit_text_box)); amountEdit.setLayoutParams(relparams); amountEdit.setHintTextColor(getResources().getColor(R.color.colorDark)); amountEdit.setPadding(edit_text_padding, edit_text_padding, edit_text_padding, edit_text_padding); amountEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen_14sp)); amountEdit.setTextColor(getResources().getColor(R.color.colorDark)); amountEdit.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); amountEdit.addTextChangedListener(onTextAmountChangedListener()); amountEdit.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_form_payment, 0, 0, 0); amountEdit.setCompoundDrawablePadding(((int) getResources().getDimension(R.dimen.editTx_padding))); amountEdit.setTag(params.getCode()); if (params.getDefValue().length() > 0 && !params.getDefValue().equals("0")) amountEdit.setText(params.getDefValue()); relativeLayout.addView(amountEdit); linearLayout.addView(relativeLayout); } else { editText.setTag(params.getCode()); if (params.getDefValue().length() > 0 && !params.getDefValue().equals("0")) editText.setText(params.getDefValue()); linearLayout.addView(editText); } if (!params.getIsVisible().equals("Y")) linearLayout.setVisibility(View.GONE); form.addView(linearLayout); } else if (params.getParamType().equalsIgnoreCase("S")) { Spinner spinner = new Spinner(getActivity()); spinner.setLayoutParams(layoutParams); spinner.setPadding(dpToPx(10), dpToPx(10), dpToPx(10), dpToPx(10)); spinner.setTag(params.getCode()); String empty_string; MobileDBHelper dbHelper = new MobileDBHelper(getActivity().getBaseContext()); refParamList = new ArrayList<>(); try { refParamList = dbHelper.getRefParamList(params.getRefCode(), null); } catch (SQLException e) { e.printStackTrace(); } spinnerList = new ArrayList<>(); for (int i = 0; i < refParamList.size(); i++) { CodeAndName codeAndName = new CodeAndName(); codeAndName.setCode(refParamList.get(i).getCode()); codeAndName.setName(refParamList.get(i).getName()); spinnerList.add(codeAndName); } if (params.getRefCode().trim().length() == 0) { EmptyCodeAndNameAdapter codeAndNameAdapter = new EmptyCodeAndNameAdapter(getActivity(), android.R.layout.simple_spinner_item, spinnerList); spinner.setAdapter(codeAndNameAdapter); } else { CodeAndNameAdapter adapter = new CodeAndNameAdapter(getActivity(), android.R.layout.simple_spinner_item, spinnerList); spinner.setAdapter(adapter); } if (params.getCode().equals("SECTOR")) { spinner.setOnItemSelectedListener(sectorListener); } else { spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (((CodeAndName) parent.getAdapter().getItem(position)).getCode().equals("empty")) { TextView selectedText = (TextView) parent.getChildAt(0); if (selectedText != null) { selectedText.setTextColor(Color.RED); } } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } if (!params.getIsVisible().equals("Y")) spinner.setVisibility(View.GONE); form.addView(spinner); if (params.getIsReadOnly().equals("Y")) spinner.setEnabled(false); if (params.getDefValue().length() > 0) { for (int index = 0; index < spinnerList.size(); index++) { if (spinnerList.get(index).getCode().equals(params.getDefValue())) { spinner.setSelection(index); break; } } } } } Button submit = parent.findViewById(R.id.btnMakePayment); submit.setAllCaps(false); submit.setOnClickListener(this); } 

Ps. On other devices, everything works, checked on Android versions <5.1 and since 6.0 everything works

  • you need to show the code where you programmatically make these View. - Andrey Mihalev
  • Added code to the question - Abdugani_T

1 answer 1

The solution was found, this page opened as a fragment and caused the following code

  getSupportFragmentManager().beginTransaction() .addToBackStack(null) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) .add(R.id.pay_company_container, fragment) .commit(); } 

It turned out that by removing the .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) field began to accept data.

that is, the Solution was

  getSupportFragmentManager().beginTransaction() .addToBackStack(null) .add(R.id.pay_company_container, fragment) .commit(); }