如何将数据从活动传递到片段?

时间:2016-05-30 17:06:37

标签: android-studio

我正在创建一个基本的应用程序,我坚持这一点,我无法将数据从活动传递到片段。

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);
                }
            });

        }



    }

Email Page

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);
    }

}

NavHeaderMainMenu1

0 个答案:

没有答案