Android实习——06

Fragment碎片
生命周期:
新建一个碎片
onAttach()
onCreate()
onCreateView() <___________
onActivityCreated()
onStart()
onResume()

碎片已激活
onPause()
onStop()
onDestroyView()__________>
onDestroy()
onDetach()

Adapter:
FragmentStatePagerAdapter:

跨页面传参(传过去 传回来):

第一个Activity

private void initIntent(){
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MainActivity.this,Main2Activity.class);
                intent.putExtra("key",text1.getText().toString());
                startActivity(intent);
            }
        });
        Intent i=getIntent();
        String value=i.getStringExtra("backname");
        text2.setText(value);

    }

第二个Activity:

btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(Main2Activity.this,MainActivity.class);
                intent.putExtra("backname",text4.getText().toString());
                startActivity(intent);
            }
        });
        Intent i=getIntent();
        String value=i.getStringExtra("key");
        text3.setText(text3.getText().toString()+value);

报错:Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without…

你可能感兴趣的:(Android实习——06)