title: How to create TextView with reflection on android?
body: <p>I'm trying to create a textview with reflection on android but I could not success and got an exception which I shown below. Can anyone share an example with me? </p>
  
  <p>the thing what I am trying to do is very simple, I will create a textview and put some text into it with calling it's setText method. </p>
  
  <pre><code>TextView x = new TextView(this);
  x.setText("asjdhjasd");
  </code></pre>
  
  <p>the codes</p>
  
  <pre><code>Class cls = Class.forName("android.widget.TextView"); 
  Class param[] = new Class[1];
  param[0] = context.getClass();
  
  Constructor ct = cls.getConstructor(param); //THROWS AN EXCEPTION HERE CALLED NO SUCH METHOD EXCEPTION.
  
  Object paramVal[] = new Object[1];
  paramVal[0] = context;
  Object retobj = ct.newInstance(paramVal);
  </code></pre>
  
  <p><strong>I solved the problem with doing this</strong></p>
  
  <pre><code>param[0] = Context.class; //instead of param[0] = context.getClass();
  </code></pre>