Home > Software engineering >  How to create a extension for the Etar Calender
How to create a extension for the Etar Calender

Time:11-25

How to create an extension for the Etar Calender in Android Studio? I want that the created event from me to be sent on WhatsApp or Messenger.

CodePudding user response:

  1. You can try these In Android Studio, create a new project and select the "Empty Activity" template.
  2. Call the activity "EtarCalendarActivity".
  3. In the AndroidManifest.xml file, add the following permissions:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
  1. Also add the following line to the manifest file:
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name">
  1. In the EtarCalendarActivity.java file, import the following classes:
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import com.etar.calendar.EtarCalendar;
import com.etar.calendar.EtarDatePicker;
import com.etar.calendar.EtarTimePicker;
  1. Add the following code to the EtarCalendarActivity class:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

setContentView(R.layout.activity_etar_calendar);

EtarCalendar etarCalendar = (EtarCalendar) findViewById(R.id.etarCalendar);

EtarDatePicker etarDatePicker =
(EtarDatePicker) findViewById(R.id.etarDatePicker);

EtarTimePicker etarTimePicker =
(EtarTimePicker) findViewById(R.id.etarTimePicker);

etarCalendar.setListener(new EtarCalendar.Listener() {
@Override
public void onDateSelected(EtarDatePicker etarDatePicker,
EtarDate etarDate) {
Toast.makeText(
EtarCalendarActivity.this,
etarDate.toString(),
Toast.LENGTH_SHORT).show();
}

@Override
public void onTimeSelected(
EtarTimePicker etarTimePicker,
EtarTime etarTime) {
Toast.makeText(
EtarCalendarActivity.this,
etarTime.toString(),
Toast.LENGTH_SHORT).show();
}
});

etarDatePicker.setListener(new EtarDatePicker.Listener() {
@Override
public void onDateSelected(
EtarDatePicker etarDatePicker,
EtarDate etarDate) {
EtarTimePicker etarTimePicker =
(EtarTimePicker) findViewById(R.id.etarTimePicker);
etarDate.set(etarDatePicker.getDate());
etarTime.set(etarTimePicker.getTime());
}
});

etarTimePicker.setListener(new EtarTimePicker.Listener() {
@Override
public void onTimeSelected(
EtarTimePicker etarTimePicker,
EtarTime etarTime) {
EtarDatePicker etarDatePicker =
(EtarDatePicker) findViewById(R.id.etarDatePicker);
etarDate.set(etarDatePicker.getDate());
}
});

}
  1. Run the application.
  • Related