I have created 3 fragments for one of my project ..this is one of them. So basically I want When ever the admin(aAccountFragment) will click on the update quote button the quote should be updated and should be reflected in AccountFragment.xml file in the user end.
For this in the admin(aAccountFragment) side I have provided and edit text where the admin can update the quote every 24hrs.and in the user end(AccountFragment) the user can only see the updated quote when ever the admin will update the quote because at user end textview is provided and in the admin end EditText is provided.
For this I have attached my aAccountFragment.xml, AccountFragment.xml,AccountFragment.java,aAccountFragment.java code.
This is my aAccountFragment.xml code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".aAccountFragment"
android:background="@drawable/ic_launcher_background">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="339dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="41dp"
android:layout_marginBottom="465dp"
android:text=" QUOTE OF THE DAY"
android:textColor="@color/black"
android:textSize="30sp" />
<EditText
android:layout_width="323dp"
android:layout_height="111dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="21dp"
android:layout_marginBottom="273dp"
android:text="-She decided to start living the life she imagined-"
android:textColor="@color/DarkRed"
android:textSize="25sp" />
<Button
android:layout_width="166dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="107dp"
android:layout_marginBottom="177dp"
android:background="@color/LightBlue"
android:text="UPDATE QUOTE"
android:textColor="@color/black"
android:textSize="20sp" />
<Button
android:id="@+id/logout1"
android:layout_width="166dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="43dp"
android:layout_marginBottom="75dp"
android:background="@color/Pink"
android:text="LOG OUT"
android:textColor="@color/black"
android:textSize="20sp" />
</RelativeLayout>
this is my aAccountFragment.java code.
public class aAccountFragment extends Fragment {
Button logout1;
public aAccountFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.afragment_account, container, false);
logout1 = view.findViewById(R.id.logout1);
logout1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(), aloginpage.class));
Toast.makeText(getActivity().getApplicationContext(), "SUCCESSFULLY LOGOUT", Toast.LENGTH_SHORT).show();
}
});
return view;
}
}
this is my AccountFragment.xml code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AccountFragment"
android:background="@drawable/ic_launcher_background">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="339dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="41dp"
android:layout_marginBottom="465dp"
android:text=" QUOTE OF THE DAY"
android:textColor="@color/black"
android:textSize="30sp" />
<TextView
android:layout_width="296dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="49dp"
android:layout_marginBottom="272dp"
android:text="-She decided to start living
the life she imagined-"
android:textColor="@color/DarkRed"
android:textSize="25sp" />
<Button
android:id="@+id/logout"
android:layout_width="166dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="28dp"
android:layout_marginBottom="75dp"
android:background="@color/Pink"
android:text="LOG OUT"
android:textColor="@color/black"
android:textSize="20sp" />
</RelativeLayout>
this is my AccountFragment.java code.
public class AccountFragment extends Fragment {
Button logout;
public AccountFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_account, container, false);
logout = view.findViewById(R.id.logout);
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(), loginpage.class));
Toast.makeText(getActivity().getApplicationContext(), "SUCCESSFULLY LOGOUT", Toast.LENGTH_SHORT).show();
}
});
return view;
}
}