View difference between Paste ID: ZRc0Jbyy and P2mV9kp3
SHOW: | | - or go back to the newest paste.
1
 Context c = parent.getContext();
2
3
                    RelativeLayout rowRoot = new RelativeLayout(c);
4
                    AbsListView.LayoutParams rowParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, targetWidth);
5
                    rowRoot.setLayoutParams(rowParams);
6
7
8
                    LinearLayout rowContainer = new LinearLayout(c);
9
                    rowContainer.setOrientation(LinearLayout.HORIZONTAL);
10
                    RelativeLayout.LayoutParams rowContainerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, targetWidth);
11
                    rowContainerParams.addRule(RelativeLayout.CENTER_IN_PARENT);
12
                    rowContainer.setLayoutParams(rowContainerParams);
13
14
15
                    TextView playsetNumber = new TextView(c);
16
                    LinearLayout.LayoutParams lps = new LinearLayout.LayoutParams(playsetNumberWidth, LinearLayout.LayoutParams.MATCH_PARENT);
17
                    playsetNumber.setLayoutParams(lps);
18
                    playsetNumber.setGravity(Gravity.CENTER);
19
                    playsetNumber.setTextSize(playsetNumberTextSize);
20
21
                    lps = new LinearLayout.LayoutParams(lotteryBallWidth, LinearLayout.LayoutParams.MATCH_PARENT);
22
                    TextView numberOne = new TextView(c);
23
                    numberOne.setLayoutParams(lps);
24
                    numberOne.setBackgroundResource(R.drawable.text_background);
25
                    numberOne.setGravity(Gravity.CENTER);
26
                    numberOne.setTextAppearance(parent.getContext(), R.style.RowTextAppearance);
27
                    numberOne.setTextSize(rowTextHeight);
28
29
                    TextView numberTwo = new TextView(c);
30
                    numberTwo.setLayoutParams(lps);
31
                    numberTwo.setBackgroundResource(R.drawable.text_background);
32
                    numberTwo.setGravity(Gravity.CENTER);
33
                    numberTwo.setTextAppearance(parent.getContext(), R.style.RowTextAppearance);
34
                    numberTwo.setTextSize(rowTextHeight);
35
36
                    TextView numberThree = new TextView(c);
37
                    numberThree.setLayoutParams(lps);
38
                    numberThree.setBackgroundResource(R.drawable.text_background);
39
                    numberThree.setGravity(Gravity.CENTER);
40
                    numberThree.setTextAppearance(parent.getContext(), R.style.RowTextAppearance);
41
                    numberThree.setTextSize(rowTextHeight);
42
43
                    lps = new LinearLayout.LayoutParams(spacingWidth, LinearLayout.LayoutParams.MATCH_PARENT);
44
                    View spacerOne = new View(c);
45
                    spacerOne.setLayoutParams(lps);
46
                    View spacerTwo = new View(c);
47
                    spacerTwo.setLayoutParams(lps);
48
                    lps = new LinearLayout.LayoutParams(rightMargin, LinearLayout.LayoutParams.MATCH_PARENT);
49
                    View spacerThree = new View(c);
50
                    spacerThree.setLayoutParams(lps);
51
52
                    final int halfExcess = excess / 2;
53
54
                    rowContainer.addView(playsetNumber);
55
                    if (excess != 0) {
56
                        lps = new LinearLayout.LayoutParams(halfExcess, LinearLayout.LayoutParams.MATCH_PARENT);
57
                        View excessSpaceLeft = new View(c);
58
                        excessSpaceLeft.setLayoutParams(lps);
59
                        rowContainer.addView(excessSpaceLeft);
60
                    }
61
                    rowContainer.addView(numberOne);
62
                    rowContainer.addView(spacerOne);
63
                    rowContainer.addView(numberTwo);
64
                    rowContainer.addView(spacerTwo);
65
                    rowContainer.addView(numberThree);
66
                    if (excess != 0) {
67
                        lps = new LinearLayout.LayoutParams(halfExcess, LinearLayout.LayoutParams.MATCH_PARENT);
68
                        View excessSpaceRight = new View(c);
69
                        excessSpaceRight.setLayoutParams(lps);
70
                        rowContainer.addView(excessSpaceRight);
71
                    }
72
                    rowContainer.addView(spacerThree);
73
                    rowRoot.addView(rowContainer);
74
75
                    TextView blockView = new TextView(c);
76
                    RelativeLayout.LayoutParams rlps =
77
                            new RelativeLayout.LayoutParams(
78
                                    upgradeOverlayWidth, getUpgradeOverlayHeight);
79
                    rlps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
80
                    rlps.addRule(RelativeLayout.CENTER_VERTICAL);
81
82
83
// lets say i wanted to make blockView below the rowContainer (the linearlayout)
84
// it'd go... NOTE it is crucial to define the id in values when doing non-xml inflation,
85
// otherwise it doesnt work for some reason (ie setId(1) won't do the trick
86
87
rowContainer.setId(R.id.some_declared_id);
88
rlps.addRule(RelativeLayout.BELOW, rowContainer.getId());
89
90
//
91
92
                    rlps.rightMargin = upgradeOverlayRightMargin;
93
94
                    blockView.setTextColor(Color.BLACK);
95
                    blockView.setLayoutParams(rlps);
96
                    blockView.setBackgroundResource(R.drawable.shadow_border);
97
98
99
                    setColor(blockView, upgradeMessage, "UPGRADE", accentColor);
100
101
                    blockView.setTextSize(rowTextSize* .6f);
102
                    blockView.setGravity(Gravity.CENTER);
103
104
105
                    blockView.setOnClickListener(new View.OnClickListener() {
106
                        @Override
107
                        public void onClick(View v) {
108
                            openPaidApp();
109
                        }
110
                    });
111
112
                    rowRoot.addView(blockView);
113
114
                    convertView = rowRoot;
115
116
117
118
119
120
121
122
                    viewHolder = new ViewHolder();
123
                    viewHolder.playsetNumber = playsetNumber;
124
125
                    viewHolder.numberOne = numberOne;
126
                    viewHolder.numberTwo = numberTwo;
127
                    viewHolder.numberThree = numberThree;
128
129
130
                    convertView.setTag(viewHolder);