title: Android Add Textview in java file, not XML
body: <p>I need to be able to add a textview to my app with code, not using the XML or Graphic interface...
  I have an imageview, but cannot figure out how to modify it to get a Textview (Im new to Android)...</p>
  
  <p>Here is my imageview code:</p>
  
  <pre><code>//Add view using Java Code
  ImageView imageView = new ImageView(AndroidAddViewActivity.this);
  imageView.setImageResource(R.drawable.icon);
  LayoutParams imageViewLayoutParams 
  = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  imageView.setLayoutParams(imageViewLayoutParams);
  
  mainLayout.addView(imageView);
  </code></pre>