Accessing the members of a simple class in Android
<p>I have a simple Java class which extends <code>View</code> in another package, and I am making a custom view using this class. I want to use it as a <code>View</code> in XML from another class, which is an <code>Activity</code>.</p>

<p>My custom <code>View</code> needs some data from that class, so I created an object of <code>Pt</code> class, which extends <code>Activity</code>.  The object is created, but when I am use that object for accessing the members of the class that extends <code>Activity</code>, it does not show any members. Am I doing something wrong, or there is a better way to do it?</p>

<p>Here is my code. I have shown what I am expecting within the comments.</p>

<pre><code>public class PlotView extends View {//class to make a custom view

    Plot_View obj_plot = new Plot_View();
    obj_plot.//  here i am expecting it to show the members of that Plot_View class which is extending Activity 

    class Pt{
        float x, y;
        Pt(float _x, float _y){
            x = _x;
            y = _y;
        }
    }

    Pt[] myPath = { new Pt(100, 100), new Pt(200, 200),    new Pt(200, 500),
                    new Pt(400, 500),    new Pt(400, 200) };

    public PlotView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public PlotView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        Paint paint = new Paint();
        paint.setColor(Color.BLUE);
        paint.setStrokeWidth(3);
        paint.setStyle(Paint.Style.STROKE);
        Path path = new Path();
        path.moveTo(myPath[0].x, myPath[0].y);

        for (int i = 1; i &lt; myPath.length; i++){
            path.lineTo(myPath[i].x, myPath[i].y);
        }
        canvas.drawPath(path, paint);
    }
}//
</code></pre>

<p>and here is my Plot_View Activity .i want to access these Arraylists defined here in this activity</p>

<pre><code>     public class Plot_View extends Activity implements OnClickListener {


        public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    setContentView(R.layout.plotview);

      calculationForPlot();

    findViewById(R.id.btn_measure).setOnClickListener(this);



     initMirrorMatrix();

     drawMatrix();
}

 private void calculationForPlot(){
     ArrayList&lt;String&gt; al_edit_A_ft = new ArrayList&lt;String&gt;();
     ArrayList&lt;String&gt; al_edit_A_inch=new ArrayList&lt;String&gt;();
     ArrayList&lt;String&gt;al_edit_B_ft=new ArrayList&lt;String&gt;(); 
     ArrayList&lt;String&gt;al_edit_B_inch= new ArrayList&lt;String&gt;();
    float x=0;
     AndroidOpenDbHelper androidOpenDbHelperObj = new AndroidOpenDbHelper(this);
        SQLiteDatabase sqliteDatabase = androidOpenDbHelperObj.getReadableDatabase();
        String q="SELECT * FROM ab_measurement WHERE job_id=" +"\""+Settings.jobid +"\"";


   Cursor  cursor = sqliteDatabase.rawQuery(q,null);

        if (cursor.moveToNext()) {
            System.out.println(cursor.getCount());
            m=Integer.parseInt(cursor.getString(4));

            do {
                try{

                float a = 0,b = 0;



                 a=(float) Double.parseDouble(cursor.getString(6));
                 String number =String.valueOf(a);
                 System.out.println("aaa ggg"+number);
                 String int_part =number.substring(0,number.indexOf("."));
                 String float_part=number.substring(number.lastIndexOf(".")+1,number.length());
                 System.out.println("aaa values"+int_part);
                 System.out.println("aaa values"+float_part);


                  al_edit_A_ft.add(int_part);
                  al_edit_A_inch.add(float_part);

                     b= (float) Double.parseDouble(cursor.getString(7));
                     String number_b =String.valueOf(b);
                     System.out.println("aaa ggg"+number_b);
                     String int_part_b =number_b.substring(0,number_b.indexOf("."));
                     String float_part_b=number_b.substring(number_b.lastIndexOf(".")+1,number_b.length());
                     System.out.println("aaa values"+int_part_b);
                     System.out.println("aaa values"+float_part_b);
                     al_edit_B_ft.add(int_part_b);
                     al_edit_B_inch.add(float_part_b);

                     x= (float) Double.parseDouble(cursor.getString(3));
                     String ft_base =String.valueOf(x);
                     System.out.println("aaa ggg"+ft_base);
                     String int_part_ft =ft_base.substring(0,ft_base.indexOf("."));
                     String float_part_inch=ft_base.substring(ft_base.lastIndexOf(".")+1,ft_base.length());
                     System.out.println("aaa values"+int_part_ft);
                     System.out.println("aaa values"+float_part_inch);


                }
                catch (Exception e) {

                }

            } while (cursor.moveToNext());
</code></pre>
