android Intent 多种用法全面介绍
2010-06-04 14:20:00 来源:WEB开发网14.
15. /** Called when the activity is first created. */
16. @Override
17. public void onCreate(Bundle savedInstanceState) {
18. super.onCreate(savedInstanceState);
19. setContentView(R.layout.main);
20.
21. m_EditText = (EditText) this.findViewById(R.id.EditText01);
22. m_EditText.setOnKeyListener(editTextKeyListener);
23. }
24.
25. private EditText.OnKeyListener editTextKeyListener = new EditText.OnKeyListener() {
26.
27. @Override
28. public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
29.
30. // action 跳转,需要在AndroidManifest.xml中配置action
31. Intent i = new Intent("android.intent.action.mydialog");
32. MyEditText.this.startActivity(i);
33.
34. return false;
35. }
36. };
37. }
Xml代 码
1. < ?xml version="1.0" encoding="utf-8"? >
2. < manifest xmlns:android="http://schemas.android.com/apk/res/android"
3. package="com.android.edit_text" android:versionCode="1"
4. android:versionName="1.0" >
5. < application android:icon="@drawable/icon" android:label="@string/app_name" >
6. < activity android:name=".MyEditText" android:label="@string/app_name" >
7. < intent-filter >
8. < action android:name="android.intent.action.MAIN" / >
9. < category android:name="android.intent.category.LAUNCHER" / >
10. < /intent-filter >
11. < /activity >
12. < !-- 配置跳转activity-- >
13. < activity android:name="com.android.dialog.MyDialog" >
14. < intent-filter >
15. < !-- 配置action路径-- >
16. < action android:name="android.intent.action.mydialog" / >
更多精彩
赞助商链接