Advertisement
LemmyNjaria

Dynamic Edittext

Jul 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1.  for (i = 0; i < checkoutItemsList.size(); i++) {
  2.              
  3.             productNames += checkoutItemsList.get(i).getCustomersBasketProduct().getProductsName();
  4.             for (j = 1; j <= getCartSize(); j++) {
  5.  
  6.                 lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
  7.                 lp.setMargins(30, 50, 30, 0);
  8.  
  9.                 //candidates name starts here
  10.                 candidatesNamesTv = new TextView(getActivity());
  11.                 candidatesNamesTv.setId(R.id.candidatesnametv);
  12.                 candidatesNamesTv.setText("" + productNames + "(" + j + ")");
  13.                 candidatesNamesTv.setTextSize(16);
  14.                 candidatesNamesTv.setTextColor(getResources().getColor(R.color.textColorSecondaryDark));
  15.                 candidatesNamesTv.setLayoutParams(lp);
  16.                 allcandidatesNamesTv.add(candidatesNamesTv);
  17.                 //Textview ends here
  18.  
  19.                 //candidates names ends here
  20.                 Drawable img = getContext().getResources().getDrawable(R.drawable.ic_person);
  21.                 img.setBounds(0, 0, 60, 60);
  22.                 candidatesNames = new AppCompatEditText(getActivity());
  23.                 candidatesNames.setBackgroundResource(R.drawable.rounded_corners_edittext_dark);
  24.                 candidatesNames.setId(R.id.candidatesname);
  25.                 candidatesNames.setHint("Candidate Full Name");
  26.                 candidatesNames.setHintTextColor(getResources().getColor(R.color.textColorPrimaryDark));
  27.                 candidatesNames.setTextColor(getResources().getColor(R.color.textColorSecondary));
  28.                 candidatesNames.setCompoundDrawables(img, null, null, null);
  29.                 candidatesNames.setCompoundDrawablePadding(20);
  30.                 candidatesNames.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
  31.                 candidatesNames.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
  32.                 candidatesNames.setLayoutParams(lp);
  33.                 allCandidatesnames.add(candidatesNames);
  34.  
  35.  
  36.                 theLayout.addView(candidatesNamesTv);
  37.                 theLayout.addView(candidatesNames);
  38.                
  39.             }
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement