

// ata sub ar work tar mane amora calculator make korte parbo
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView textView;
private Button button;
private DatePicker datePicker;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = this.<TextView>findViewById(R.id.textid2);
button = this.<Button>findViewById(R.id.buttonid);
datePicker = this.<DatePicker>findViewById(R.id.datepickerid);
textView.setText(current());
button.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
textView.setText(current());
}
});
}
String current (){
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(datePicker.getMonth()+1 +" \n");
stringBuffer.append(datePicker.getDayOfMonth()+"\n");
stringBuffer.append(datePicker.getYear());
return stringBuffer.toString();
}
}
Post a Comment