android activity method call
<p>I am new to android development. Today i tried something that i created a project called <strong>androidPickerviws</strong> .</p>

<p>In that project i created two activities and in Timepicker.java activity there is method called <strong>displayTime(hours,minute);</strong>. Now my doubt is can i use this mehtod displayTime() in Datepicker.java activity. If so, how can i do it..</p>

<p>Here iam providing my Timepicker.java activity code</p>

<pre><code>package picker.view;

// imports...


public class Timepicker extends Activity{
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    LinearLayout linearlayout=new LinearLayout(this);
    linearlayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutparams=new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    LayoutParams params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);

    final TimePicker timepicker=new TimePicker(this);
    linearlayout.addView(timepicker, params);   

    Button ok=new Button(this);
    ok.setText("OK");
    linearlayout.addView(ok, params);
    addContentView(linearlayout,layoutparams);

    ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            final int hours=timepicker.getCurrentHour();
            final int minute=timepicker.getCurrentMinute();
            displayTime(hours,minute);
        }

        private void displayTime(int hours, int minute) {
            if(hours==0)
                Toast.makeText(getBaseContext(), "Time saved is 12 : "+minute+" AM", Toast.LENGTH_SHORT).show();
            else if(hours&lt;12)
                Toast.makeText(getBaseContext(), "Time saved is "+hours+" : "+minute+" AM", Toast.LENGTH_SHORT).show();
            else if(hours==12)
                Toast.makeText(getBaseContext(), "Time saved is "+hours+" : "+minute+" PM", Toast.LENGTH_SHORT).show();
            else 
                Toast.makeText(getBaseContext(), "Time saved is "+(hours-12)+" : "+minute+" PM", Toast.LENGTH_SHORT).show();

        }
    });
}
   }
</code></pre>

<p>Thank you,..... </p>
