好贷网好贷款

Android Activity跳转学习笔记

发布时间:2016-12-4 9:59:18 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"Android Activity跳转学习笔记",主要涉及到Android Activity跳转学习笔记方面的内容,对于Android Activity跳转学习笔记感兴趣的同学可以参考一下。

MainActivity.java package com.Ldci.intentdome; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { private Button btnButton ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnButton = (Button)findViewById(R.id.button1); btnButton.setOnClickListener(listener); } private OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setClass(MainActivity.this, IntentActivity.class); intent.putExtra("name", "xiaonan"); startActivity(intent); } }; @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; } } IntentActivity.java package com.Ldci.intentdome; import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class IntentActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_intent); Intent intent = getIntent(); String string = intent.getStringExtra("name"); System.out.println(string); } } AndroidManifest.xml <activity android:name="com.Ldci.intentdome.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.Ldci.intentdome.IntentActivity"> </activity>

上一篇:[Oracle] to_date() 与 to_char() 日期和字符串转换[博客园—gshine]
下一篇:org.xml.sax

相关文章

相关评论