FirstFragment extends Fragment and I know setContentView and findViewById needs to extend from appcompactactivity. But I don't know to use interface to extends both of them. Is there any solution to use setContentView or findViewById (This code is FirstFragment java file and I added FloatingActionButton) Here is my Code
import android.app.Fragment;
import android.content.Intent;
import android.media.Image;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
public class FirstFragment extends android.support.v4.app.Fragment{
FloatingActionButton b1;
public FirstFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (FloatingActionButton) findViewById(R.id.fab);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent1 = new Intent(getApplicationContext(),ShowMe_fab.class);
startActivity(intent1);
}
});
}
}