public class ApplyLeaveFrag extends Fragment implements OnClickListener {
static TextView FROM,TO;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.apply_leave_fragment, container,
false);
FROM = (TextView) view.findViewById(R.id.textView1);
TO = (TextView) view.findViewById(R.id.textView2);
....
}
...
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
FROM.setText("from");
TO.setText("TO");
}
}
Edit: for the question in comment
Declare a static boolean class variable
static boolean check=true;
On click
public void onClick(View v) {
switch (v.getId()) {
case R.id.textView1:
ShowCal();
check=true;
break;
case R.id.textView2:
ShowCal();
check=false;
break;
}
}
then
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
if(check==true)
{
// set from text
}
else if(check ==false)
{
// set to text
}
}