Q:

Android - How to inflate an activity layout to fragment?

Hi I am still beginner in android programming. I have made tablayout in my program and when I click the tab I'd like the fragment to display the activity layout. 
The purpose is for the widget inside the activity such as button' and recycler view'functions can be done. 
I've tried to inflate activity layout it displayed exactly what I want however when I click a button inside, the application stop working instead of toast that what i have set. 
Is there any other method? Please help me
Here is the logcat:
05-27 12:43:41.720 12549-12549/? E/AndroidRuntime: FATAL EXCEPTION: main
                                               Process: com.rumahdosen.www.rumahdosen, PID: 12549
                                               java.lang.IllegalStateException: Could not find method clickLogin(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'btnLogin'
                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:325)
                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
                                                   at android.view.View.performClick(View.java:4463)
                                                   at android.view.View$PerformClick.run(View.java:18770)
                                                   at android.os.Handler.handleCallback(Handler.java:808)
                                                   at android.os.Handler.dispatchMessage(Handler.java:103)
                                                   at android.os.Looper.loop(Looper.java:193)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5292)
                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                   at java.lang.reflect.Method.invoke(Method.java:515)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
                                                   at dalvik.system.NativeStart.main(Native Method)

This is the java class for fragment
public class FragmentFriends extends Fragment {
@Nullable
@Override

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    return inflater.inflate(R.layout.activity_login,container,false);
}
}

Below is the xml file of activity_login
<?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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.rumahdosen.www.rumahdosen.LoginActivity">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Login"
    android:id="@+id/btnLogin"
    android:layout_below="@+id/etPswd"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="46dp"
    android:onClick="clickLogin"/>
</RelativeLayout>

Below is the LoginActivity.java
public class LoginActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
}

public void clickLogin(View view){
           Toast.makeText(getApplicationContext(),"test",Toast.LENGTH_LONG).show();
}
}

A:

Remove clickLogin() attribute from xml file.
OR
create method clickLogin(View view) in fragment,
public void clickLogin(View view) {

}

replace
Toast.makeText(getApplicationContext(),"test",Toast.LENGTH_LONG).show();

with
Toast.makeText(LoginActivity.this,"test",Toast.LENGTH_LONG).show();

