In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the example analysis of MainActivity jumping to second. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
MainActivity side: an input box, a button. After entering the content, click the button to jump to the second side and display the input.
Public class MainActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main) / * * the condition that the findViewById () method returns a non-empty object: * 1) setContentView () execute first * 2) id exists in the currently loaded layout * / final EditText edittext = (EditText) findViewById (R.id.editText1); Button button = (Button) findViewById (R.id.main_button1) Button.setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {Intent intent = new Intent (MainActivity.this, Second.class); / / create an intent and jump from here to another String username = edittext.getText () .toString () Intent.putExtra ("user", username); / / get the content through key and join intent startActivity (intent); / / start Activity}}) } @ 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;}}
Second side:
/ * add Activity: * 1) create a class, inherit Activity * 2) specify: override the onCreate () method, * setContentView () create a layout file * 3) configure Activity * / public class Second extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.second) in the Androidmanifest file Intent intent = getIntent (); String username = intent.getStringExtra ("user"); / / get string TextView textView = (TextView) findViewById (R.id.textView1); textView.setText (username) through key.} this is the end of the example analysis on the jump of MainActivity to second. I hope the above can be helpful and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.