title: Returning values from custom view
body: <p>I have made a class <code>ShowWeight</code> extending <code>LinearLayout</code>, which has two custom Views as Inner classes. I am using this class by means of an XML tag in the main.xml :</p>
  <pre><code>&lt;org.test.ShowWeight  android:id=&quot;@+id/sw&quot;..................../&gt;
  </code></pre>
  <p>There are two public variables in the ShowWeight class, whose changing values need to be captured in the main activity, which uses <code>main.xml</code> as its view.</p>
  <p>How do I do this?
  I tried this in the main activity :</p>
  <pre><code>ShowWeight sw=(ShowWeight)this.findViewById(R.id.sw);
  Log.d(&quot;test&quot;,sw.getContentDescription().toString());
  </code></pre>
  <p>and this in the showWeight class:</p>
  <pre><code>this.setContentDescription(/*required value */);
  </code></pre>
  <p>This resulted in a <code>NullPointerException</code>.</p>
  <p>Would appreciate some suggestions (Database, static variables, not an option)</p>
  <h3>Update:</h3>
  <p>Unfortunately, I am not permitted to post any of the code, I apologize if I seem vague, nevertheless I'm sure the <code>ShowWeight</code> class hasn't altered anything that might be causing the problem.</p>
  <p>The ShowWeight class, which I have added to the main.xml view by means of an XML tag appears fine and functions properly.</p>
  <p>When I use <code>ShowWeight sw=(ShowWeight)this.findViewById(R.id.sw);</code> in the Main Activity and then Toast or print ShowWeight I am getting 'null' . Also the <code>setContentDescription(),getContentDescription()</code> shouldn't throw errors because I've given a default contentDescription in the XML tag for ShowWeight.</p>