1 Program 9: Meeting Schedule
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<[Link]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/design_default_color_error"
android:theme="@style/[Link]">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/purple_500"
android:gravity="center"
android:minHeight="?actionBarSize"
android:padding="@dimen/appbar_padding"
android:text="Meeting Details"
android:textAlignment="center"
android:textAppearance="@style/[Link]
e" />
<[Link]
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="37dp"
android:background="#FFEA6b"
app:tabIndicatorColor="#00E6FF" />
</[Link]>
<[Link]
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="499dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</[Link]>
</[Link]>
Mobile Application Development – 18CSMP68
2 Program 9: Meeting Schedule
[Link]:
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".[Link]">
<TextView
android:id="@+id/section_label"
android:text="Schedule Meeting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
</[Link]>
[Link]:
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent">
<EditText
android:id="@+id/txtDate"
android:layout_width="212dp"
android:layout_height="50dp"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="DD/MM/YYYY"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/mDate"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/txtTime"
android:layout_width="212dp"
android:layout_height="54dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:hint="hh:mm"
Mobile Application Development – 18CSMP68
3 Program 9: Meeting Schedule
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/txtDate" />
<TextView
android:id="@+id/mDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:text="Date:"
android:textAppearance="@style/[Link]"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Time:"
android:textAppearance="@style/[Link]"
app:layout_constraintEnd_toStartOf="@+id/txtTime"
app:layout_constraintHorizontal_bias="0.117"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mDate" />
<TextView
android:id="@+id/txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="Meeting Agenda:"
android:textAppearance="@style/[Link]"
app:layout_constraintBottom_toTopOf="@+id/btn1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt2"
app:layout_constraintVertical_bias="0.131" />
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Meeting Schedule"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.331"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtAgenda"
app:layout_constraintVertical_bias="0.782" />
<EditText
android:id="@+id/txtAgenda"
android:layout_width="212dp"
android:layout_height="50dp"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/txt3"
app:layout_constraintTop_toBottomOf="@+id/txtTime" />
<CalendarView
Mobile Application Development – 18CSMP68
4 Program 9: Meeting Schedule
android:id="@+id/mCal"
android:layout_width="385dp"
android:layout_height="305dp"
android:background="#AFB42B"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.575" />
</[Link]>
[Link]:
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Select Date to get Meeting Details"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editTextDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.535"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.047" />
<CalendarView
android:id="@+id/calendarView"
android:layout_width="263dp"
android:layout_height="249dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.679"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextDate" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search to get Meeting Details"
app:layout_constraintBottom_toBottomOf="parent"
Mobile Application Development – 18CSMP68
5 Program 9: Meeting Schedule
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/calendarView"
app:layout_constraintVertical_bias="0.0" />
</[Link]>
Java Code:
package [Link];
import [Link];
import
[Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
SectionsPagerAdapter sectionsPagerAdapter = new
SectionsPagerAdapter(this, getSupportFragmentManager());
ViewPager viewPager = findViewById([Link].view_pager);
[Link](sectionsPagerAdapter);
TabLayout tabs = findViewById([Link]);
[Link](viewPager);
}
}
[Link]:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class DataBaseConn extends SQLiteOpenHelper {
public DataBaseConn(Context context) {
super(context,"[Link]",null,1);
}
Mobile Application Development – 18CSMP68
6 Program 9: Meeting Schedule
@Override
public void onCreate(SQLiteDatabase db) {
[Link]("create Table meetingTbl(date TEXT,time TEXT, agenda
TEXT)");
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
[Link]("drop Table if exists meetingTbl");
}
public boolean insertvalue(String d, String t, String agd){
SQLiteDatabase DB=[Link]();
ContentValues cv = new ContentValues();
[Link]("date",d);
[Link]("time",t);
[Link]("agenda",agd);
long res=[Link]("meetingTbl",null,cv); //query to insert
if(res==-1){
return false;
}
else
return true;
}
public Cursor fetch(String d){
SQLiteDatabase DB=[Link]();
// String sqlquery="select name from MDTbl where date='19/3/21' AND
time='Afternoon'";
// Cursor c = [Link](sqlquery,null);
Cursor c = [Link]("Select time,agenda from meetingTbl where
date='"+d+"' ",null);
return c;
}
[Link]:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class DBMS extends SQLiteOpenHelper {
public DBMS(@Nullable Context context, @Nullable String name, @Nullable
[Link] factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
Mobile Application Development – 18CSMP68
7 Program 9: Meeting Schedule
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
}
}
[Link]:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import static [Link];
public class Fragment1 extends Fragment {
EditText date,time,agenda;
DataBaseConn dbc;
CalendarView calendarView;
Button btn;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState) {
View
view=[Link]([Link].fragment_layout1,container,false);
date=[Link]([Link]);
time=[Link]([Link]);
agenda=[Link]([Link]);
btn=[Link]([Link].btn1);
calendarView=[Link]([Link]);
dbc=new DataBaseConn(getActivity()); //need to initialize here
only
[Link]([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
closeKeyBoard();
[Link]([Link]);
[Link](new
[Link]() {
@Override
public void onSelectedDayChange(@NonNull CalendarView
view, int year, int month, int dayOfMonth) {
String d=dayOfMonth+"/"+(month+1)+"/"+year;
[Link](d);
[Link]([Link]);
}
Mobile Application Development – 18CSMP68
8 Program 9: Meeting Schedule
});
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
String mdate,mTime,mAgenda;
mdate=[Link]().toString();
mTime=[Link]().toString();
mAgenda=[Link]().toString();
Boolean insert=[Link](mdate,mTime,mAgenda);
if(insert==true){
[Link](getActivity(),"Data
Inserted",Toast.LENGTH_SHORT).show();
}
else
[Link](getActivity(),"Data NOT
Inserted",Toast.LENGTH_SHORT).show();
//[Link]("NOT INSERTED");
});
return view;
}
private void closeKeyBoard(){
View view = getActivity().getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)
getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
[Link]([Link](), 0);
}
[Link]:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
Mobile Application Development – 18CSMP68
9 Program 9: Meeting Schedule
import [Link];
import [Link];
import [Link].R;
import [Link];
public class Fragment2 extends Fragment {
EditText date;
CalendarView cal;
Button btn1;
DataBaseConn dbc;
TextView t;
// String med="";
// String med1="";
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState) {
View
view=[Link]([Link].fragment2_layout,container,false);
date=[Link]([Link]);
cal=[Link]([Link]);
btn1=[Link]([Link].btn2);
dbc=new DataBaseConn(getActivity());
// t=()
[Link](new [Link]()
{
@Override
public void onSelectedDayChange(@NonNull CalendarView view, int
year, int month, int dayOfMonth) {
String d=dayOfMonth+"/"+(month+1)+"/"+year;
[Link](d);
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
String d1=[Link]().toString();
StringBuffer res=new StringBuffer();
Cursor c=[Link](d1);
int count=[Link]();
[Link]();
if(count>0) {
do {
[Link]([Link]([Link]("agenda"))+"\t"+"at"+"\t"+[Link]
ng([Link]("time")));
[Link]("\n");
//med =
([Link]([Link]([Link]("agenda"))));
//med1 =
([Link]([Link]([Link]("time"))));
}while ([Link]());
[Link](getActivity(), res,
Toast.LENGTH_LONG).show();
}
else
{
[Link](getActivity(), "No Meeting on This
Day....", Toast.LENGTH_LONG).show();
Mobile Application Development – 18CSMP68
10 Program 9: Meeting Schedule
}
});
return view;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
[Link](savedInstanceState);
}
}
Mobile Application Development – 18CSMP68
11 Program 9: Meeting Schedule
Output:
Mobile Application Development – 18CSMP68