Code example for View

Methods: getContext

0
    super(context, null, android.R.attr.buttonStyleInset);
    setNumber(n);
    setOnClickListener(new OnClickListener() {
      @Override 
      public void onClick(View v) {
        Toast.makeText(v.getContext(), "Clicked button " + number, Toast.LENGTH_SHORT).show();
      } 
    }); 
  } 
 
  public int getNumber() { 
    return number;
  } 
 
  public void setNumber(int number) {
    this.number = number;
    setText(Integer.toString(number));
  } 
 
  @Override 
  public String toString() {