title: How to add a custom class that extends View to Main Activity?
body: <p>I have problems with adding a custom class to my Main Activity.</p>
  
  <p>code in my custom class:</p>
  
  <pre><code>public class DetailView extends View {
  
      public DetailView(Context context) {
          super(context);
  
          this.setBackgroundColor(0xFF00FF00 );
  
  
  
      }
  }
  </code></pre>
  
  <p>code in main activity:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      linearLayout = (LinearLayout) findViewById(R.id.linearLayout1);
  
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      linearLayout.setOrientation(LinearLayout.VERTICAL);
  
  
      txt = new TextView(this);
      txt.setText("hello");
      txt.setId(6);
      txt.setLayoutParams(params);
      linearLayout.addView(txt);
  
      DetailView detailView = new DetailView(this.getApplicationContext());
      linearLayout.addView(detailView);
  
  }
  </code></pre>
  
  <p>Why can't is see the detailView? 
  Im new to android development so I need any help I can get, or some good links or anything. Thanks</p>