标签:des android style blog http color io ar java
============问题描述============
public class MainActivity extends Activity { String Tag="MainActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.v(Tag, "mainOnCreate"); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent=new Intent(getApplicationContext(),TwoActivity.class); intent.putExtra("name", "guanguan"); startActivity(intent); } }); //bt.setOnClickListener(l); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public void onResume() { super.onResume(); Log.v(Tag, "mainOnResume"); } public void onPause() { super.onPause(); Log.v(Tag, "mainOnPause"); } public void onStop() { super.onStop(); Log.v(Tag, "mainOnstop"); } public void onDestory() { super.onDestroy(); Log.v(Tag, "mainonDestory"); } public void onRestart() { super.onRestart(); Log.v(Tag, "mainonRestart"); } }
public class TwoActivity extends Activity{ String Tag="MainActivity"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.two_activity); Log.v(Tag, "TwoOnCreate"); TextView textview=(TextView)findViewById(R.id.textView2); Intent intent=getIntent(); String name=(String) intent.getCharSequenceExtra("name"); textview.setText("欢迎你"+name); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } public void onResume() { super.onResume(); Log.v(Tag, "twoOnresume"); } public void onPause() { super.onPause(); Log.v(Tag, "twoOnPause"); } public void onStop() { super.onStop(); Log.v(Tag, "twoOnstop"); } public void onDestory() { super.onDestroy(); Log.v(Tag, "twoonDestory"); } public void onRestart() { super.onRestart(); Log.v(Tag, "twoonRestart"); } }
============解决方案1============
============解决方案2============
这是Avtivity启动模式引起的问题吗??????????
标签:des android style blog http color io ar java
原文地址:http://www.cnblogs.com/yiguobei99/p/4041915.html