Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.05 KB | None | 0 0
  1. TableRow tr = new TableRow(this);
  2.  
  3.             tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
  4.             tr.setId(x);
  5.  
  6.             TextView bookTextView = new TextView(this);
  7.             TextView borrowedTextView = new TextView(this);
  8.             TextView dueDateTextView = new TextView(this);
  9.             TextView numRenewalsTextView = new TextView(this);
  10.  
  11.             bookTextView.setText("hey");
  12.             bookTextView.setLayoutParams(new TableRow.LayoutParams(44 , TableRow.LayoutParams.WRAP_CONTENT));
  13.             bookTextView.setSingleLine(false);
  14.  
  15.             borrowedTextView.setText("hey");
  16.             borrowedTextView.setLayoutParams(new TableRow.LayoutParams(78 , TableRow.LayoutParams.WRAP_CONTENT));
  17.             borrowedTextView.setSingleLine(false);
  18.  
  19.             dueDateTextView.setText("hey");
  20.             dueDateTextView.setLayoutParams(new TableRow.LayoutParams(72 , TableRow.LayoutParams.WRAP_CONTENT));
  21.             dueDateTextView.setSingleLine(false);
  22.  
  23.             numRenewalsTextView.setText("hey");
  24.             numRenewalsTextView.setLayoutParams(new TableRow.LayoutParams(119 , TableRow.LayoutParams.WRAP_CONTENT));
  25.             numRenewalsTextView.setSingleLine(false);
  26.  
  27.             Button b1 = new Button(this);
  28.             Button b2 = new Button(this);
  29.  
  30.             b1.setText("Renew");
  31.             b2.setText("Return");
  32.  
  33.             b1.setTag("Renew" + x);
  34.             b2.setTag("Return" + x);
  35.  
  36.             b1.setOnClickListener(new View.OnClickListener(){
  37.                 @Override
  38.                 public void onClick(View v){
  39.                     int duration = Toast.LENGTH_LONG;
  40.                     Toast.makeText(getApplicationContext(), v.getTag().toString() ,duration).show();
  41.                 }
  42.             });
  43.  
  44.             b2.setOnClickListener(new View.OnClickListener(){
  45.                 @Override
  46.                 public void onClick(View v){
  47.                     int duration = Toast.LENGTH_LONG;
  48.                     Toast.makeText(getApplicationContext(), v.getTag().toString() ,duration).show();
  49.                 }
  50.             });
  51.  
  52.             b1.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
  53.             b2.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
  54.  
  55.             tr.addView(bookTextView);
  56.             tr.addView(borrowedTextView);
  57.             tr.addView(dueDateTextView);
  58.             tr.addView(numRenewalsTextView);
  59.  
  60.             LinearLayout actions = new LinearLayout(this);
  61.  
  62.             actions.setLayoutParams(new TableRow.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, 140));
  63.             actions.setOrientation(LinearLayout.VERTICAL);
  64.  
  65.             actions.addView(b1);
  66.             actions.addView(b2);
  67.  
  68.             tr.addView(actions);
  69.  
  70.             tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement