CopyPastor

Detecting plagiarism made easy.

Score: 0.7626230120658875; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-05-15
by ORBIT

Original Post

Original - Posted on 2013-08-13
by Fredigato



            
Present in both answers; Present only in the new answer; Present only in the old answer;

> You shouldn't be using an item defined in the Layout XML in order to > create more instances of it. You should either create it in a separate > XML and inflate it or create the TableRow programmaticaly. If creating > them programmaticaly, should be something like this:
public void init(){ TableLayout ll = (TableLayout) findViewById(R.id.displayLinear); for (int i = 0; i <2; i++) { TableRow row= new TableRow(this); TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT); row.setLayoutParams(lp); checkBox = new CheckBox(this); tv = new TextView(this); addBtn = new ImageButton(this); addBtn.setImageResource(R.drawable.add); minusBtn = new ImageButton(this); minusBtn.setImageResource(R.drawable.minus); qty = new TextView(this); checkBox.setText("hello"); qty.setText("10"); row.addView(checkBox); row.addView(minusBtn); row.addView(qty); row.addView(addBtn); ll.addView(row,i); //Dynamic Button Button myButton = new Button(this); myButton.setText("Push Me"); LinearLayout ll = (LinearLayout)findViewById(R.id.buttonlayout); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.addView(myButton, lp); } }
You shouldn't be using an item defined in the Layout XML in order to create more instances of it. You should either create it in a separate XML and inflate it or create the TableRow programmaticaly. If creating them programmaticaly, should be something like this:
public void init(){ TableLayout ll = (TableLayout) findViewById(R.id.displayLinear);
for (int i = 0; i <2; i++) {
TableRow row= new TableRow(this); TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT); row.setLayoutParams(lp); checkBox = new CheckBox(this); tv = new TextView(this); addBtn = new ImageButton(this); addBtn.setImageResource(R.drawable.add); minusBtn = new ImageButton(this); minusBtn.setImageResource(R.drawable.minus); qty = new TextView(this); checkBox.setText("hello"); qty.setText("10"); row.addView(checkBox); row.addView(minusBtn); row.addView(qty); row.addView(addBtn); ll.addView(row,i); } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;