我正在创建一个基本的应用程序,我坚持这一点,我无法将数据从活动传递到片段。
EmailPage.java
public class EmailPage extends AppCompatActivity{
ImageButton btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emailpage);
btn = (ImageButton) findViewById(R.id.emailButton);
btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(EmailPage.this, YourName.class);
startActivity(i);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_right);
}
});
}
}
NavHeaderMainMenu1.java
public class NavHeaderMainMenu1 extends Fragment {
public NavHeaderMainMenu1() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.nav_header_main_menu1, container , false);
}
}