Hey Bucky,
I love your tutorials on android studio. I am stuck in middle of the fragment app where my main activity is not following the reference of the bottom section fragment. This is the bottom section.


import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jbtech.fragment.R;

/**
* Created by Jeet on 1/24/2016.
*/
public class bottomsectionfragment extends Fragment {

private static TextView bottomfirst,bottomsecond;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.bottom_section,container,false);

bottomfirst =(TextView)view.findViewById(R.id.bottomfirst);
bottomsecond=(TextView)view.findViewById(R.id.bottomsecond);

return super.onCreateView(inflater, container, savedInstanceState);

}
public void setmemetext(String top,String bottom){
bottomfirst.setText(top);
bottomsecond.setText(bottom);
}
}

 this is the top section:

/**
* Created by Jeet on 1/24/2016.
*/
package com.jbtech.fragment;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;


import com.jbtech.fragment.R;


public class topsectionfragment extends Fragment {
@Nullable
// private Context context;
topsectionlistener activityComander;
public interface topsectionlistener {
public void creatememe(String top,String bottom);
// Context context= new Con
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
try{
activityComander=(topsectionlistener) context;
}catch(ClassCastException e){
throw new ClassCastException(context.toString());
}
}

private static EditText topsection,bottomsection;
private static Button redbutton;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.top_section,container,false);
topsection=(EditText)view.findViewById(R.id.topsection);
bottomsection=(EditText)view.findViewById(R.id.bottomsection);
redbutton=(Button)view.findViewById(R.id.redbutton);

redbutton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
onclick(v);

}
}
);

return super.onCreateView(inflater, container, savedInstanceState);
}
public void onclick(View view){
activityComander.creatememe(topsection.getText().toString(),bottomsection.getText().toString());

}
}

And this is the main section

package com.jbtech.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import com.jbtech.fragment.bottomsectionfragment;

class MainActivity extends FragmentActivity implements com.jbtech.fragment.topsectionfragment.topsectionlistener{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


}

@Override
public void creatememe(String top, String bottom) {
bottomsectionfragment botfrag=(bottomsectionfragment)getSupportFragmentManager().findFragmentById(R.id.bottomsection);
botfrag.setmemetext(top,bottom);

}




}

The bottom button is throwing a type cast error. Can you please help me out.

Regards
Jeet