Advertisement
Pit_Anonim

Untitled

May 3rd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. private void initInformation(){
  2. a = findViewById(R.id.example);
  3.  
  4. params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
  5. ViewGroup.LayoutParams.WRAP_CONTENT);
  6.  
  7. paramsHelp = params;
  8. paramsHelp.setMargins(0,0,0,(int) pxFromDp(10));
  9.  
  10. for (int i = 0; i < text.length; i++) {
  11. cardText = new ArrayList<>();
  12. for (int b = 0; i < text.length; i++, b++) {
  13. if (cardText.size() != 0 && text[i].substring(text[i].length() - 1).equals(":")) {
  14. i--;
  15. break;
  16. } else if (text[i].substring(text[i].length() - 1).equals(":")) {
  17. cardText.add(text[i]);
  18. i++;
  19. for (; i < text.length; i++) {
  20. if (text[i].substring(0, 1).equals("-")) {
  21. cardText.add(cardText.size() + ")" + text[i].substring(1));
  22. } else {
  23.  
  24. i--;
  25. break;
  26. }
  27. }
  28. } else {
  29. cardText.add(text[i]);
  30. break;
  31. }
  32. }
  33.  
  34. cardView = new CardView(this);
  35. cardView.setLayoutParams(paramsHelp);
  36.  
  37. cardView.setPadding((int) pxFromDp(4),(int) pxFromDp(4),(int) pxFromDp(4),(int) pxFromDp(4));
  38. cardView.setElevation(pxFromDp(2));
  39.  
  40. cardLayout = new LinearLayout(this);
  41. cardLayout.setLayoutParams(params);
  42. cardLayout.setOrientation(LinearLayout.VERTICAL);
  43. cardLayout.setPadding((int) pxFromDp(10),(int) pxFromDp(10),(int) pxFromDp(10),(int) pxFromDp(10));
  44.  
  45. textView = new TextView(this);
  46. textView.setLayoutParams(params);
  47. textView.setTextAppearance(this, android.R.style.TextAppearance_Medium);
  48. textView.setTextColor(Color.BLACK);
  49. textView.setText(cardText.get(0));
  50.  
  51. cardLayout.addView(textView);
  52. for (int b = 1; b < cardText.size(); b++) {
  53. textView = new TextView(this);
  54. textView.setLayoutParams(params);
  55. textView.setTextAppearance(this, android.R.style.TextAppearance_Medium);
  56. textView.setPadding(0,(int) pxFromDp(10), 0,0);
  57. textView.setTextColor(Color.DKGRAY);
  58. textView.setText(cardText.get(b));
  59. cardLayout.addView(textView);
  60. }
  61. cardView.addView(cardLayout);
  62. a.addView(cardView);
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement