Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. public class Menu extends ListActivity {
  2.  
  3. private String mstring[] = { "MainActivity", "Activity2", "Activity3",
  4. "Activity4" };
  5.  
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. // TODO Auto-generated method stub
  9. super.onCreate(savedInstanceState);
  10. setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, mstring));
  11. }
  12.  
  13. @Override
  14. public void onListItemClick(ListView l, View v, int position, long id) {
  15. // TODO Auto-generated method stub
  16. super.onListItemClick(l, v, position, id);
  17. String positn = mstring[position];
  18.  
  19. try {
  20. Class ourclass = Class.forName("com.example.list" + positn);
  21. Intent inten = new Intent(Menu.this, ourclass);
  22. startActivity(inten);
  23. } catch (ClassNotFoundException e) {
  24. // TODO Auto-generated catch block
  25. e.printStackTrace();
  26.  
  27. }
  28.  
  29. 04-12 13:32:27.728: W/System.err(15518): java.lang.ClassNotFoundException: com.example.apaooo.MainActivity
  30. 04-12 13:32:27.728: W/System.err(15518): at java.lang.Class.classForName(Native Method)
  31. 04-12 13:32:27.728: W/System.err(15518): at java.lang.Class.forName(Class.java:204)
  32. 04-12 13:32:27.728: W/System.err(15518): at java.lang.Class.forName(Class.java:169)
  33. 04-12 13:32:27.728: W/System.err(15518): at com.example.appaooo.Menu.onListItemClick(Menu.java:29)
  34. 04-12 13:32:27.738: W/System.err(15518): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
  35. 04-12 13:32:27.738: W/System.err(15518): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
  36. 04-12 13:32:27.738: W/System.err(15518): at android.widget.AbsListView.performItemClick(AbsListView.java:1104)
  37. 04-12 13:32:27.738: W/System.err(15518): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2792)
  38. 04-12 13:32:27.738: W/System.err(15518): at android.widget.AbsListView$1.run(AbsListView.java:3468)
  39. 04-12 13:32:27.738: W/System.err(15518): at android.os.Handler.handleCallback(Handler.java:730)
  40. 04-12 13:32:27.738: W/System.err(15518): at android.os.Handler.dispatchMessage(Handler.java:92)
  41. 04-12 13:32:27.738: W/System.err(15518): at android.os.Looper.loop(Looper.java:213)
  42. 04-12 13:32:27.738: W/System.err(15518): at android.app.ActivityThread.main(ActivityThread.java:5225)
  43. 04-12 13:32:27.738: W/System.err(15518): at java.lang.reflect.Method.invokeNative(Native Method)
  44. 04-12 13:32:27.738: W/System.err(15518): at java.lang.reflect.Method.invoke(Method.java:525)
  45. 04-12 13:32:27.738: W/System.err(15518): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
  46. 04-12 13:32:27.738: W/System.err(15518): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
  47. 04-12 13:32:27.738: W/System.err(15518): at dalvik.system.NativeStart.main(Native Method)
  48. 04-12 13:32:27.738: W/System.err(15518): Caused by: java.lang.NoClassDefFoundError: com/example/apaooo/MainActivity
  49. 04-12 13:32:27.748: W/System.err(15518): ... 18 more
  50. 04-12 13:32:27.748: W/System.err(15518): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.apaooo.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.appaooo-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.appaooo-2, /vendor/lib, /system/lib]]
  51. 04-12 13:32:27.748: W/System.err(15518): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
  52. 04-12 13:32:27.748: W/System.err(15518): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  53. 04-12 13:32:27.748: W/System.err(15518): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  54. 04-12 13:32:27.748: W/System.err(15518): ... 18 more
  55.  
  56. package com.example.appaooo;
  57. import android.app.Activity;
  58. import android.content.Context;
  59. import android.content.Intent;
  60. import android.os.Bundle;
  61. import android.view.View;
  62. import android.view.View.OnClickListener;
  63. import android.widget.Button;
  64.  
  65. public class MainActivity extends Activity {
  66.  
  67. Button btn;
  68. @Override
  69. protected void onCreate(Bundle savedInstanceState) {
  70. super.onCreate(savedInstanceState);
  71. setContentView(R.layout.activity_main);
  72.  
  73. final Context context = this;
  74. btn = (Button) findViewById(R.id.btnGeo);
  75.  
  76. btn.setOnClickListener(new OnClickListener() {
  77.  
  78. @Override
  79. public void onClick(View arg0) {
  80. // TODO Auto-generated method stub
  81. Intent intent = new Intent(context, WebViewActivity.class);
  82. startActivity(intent);
  83. }
  84. });
  85. }
  86.  
  87. <?xml version="1.0" encoding="utf-8"?>
  88. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  89. package="com.example.appaooo"
  90. android:versionCode="1"
  91. android:versionName="1.0" >
  92. <uses-permission android:name="android.permission.INTERNET" />
  93. <uses-sdk
  94. android:minSdkVersion="8"
  95. android:targetSdkVersion="18" />
  96.  
  97. <application
  98. android:allowBackup="true"
  99. android:icon="@drawable/ic_launcher"
  100. android:label="@string/app_name"
  101. android:theme="@style/AppTheme" >
  102.  
  103. <activity
  104. android:theme="@style/customTheme"
  105. android:name="com.example.appaooo.Menu"
  106. android:screenOrientation="portrait"
  107. android:label="@string/app_name"
  108. >
  109. <intent-filter>
  110. <action android:name="android.intent.action.MAIN" />
  111.  
  112. <category android:name="android.intent.category.LAUNCHER" />
  113. </intent-filter>
  114. </activity>
  115. <activity android:name="com.example.appaooo.MainActivity"
  116. android:label="@string/app_name" ></activity>
  117.  
  118. </application>
  119.  
  120. Class ourclass = Class.forName("com.example.list" + positn);// .missing
  121.  
  122. Class ourclass = Class.forName("com.example.list."+positn);
  123.  
  124. com.example.apaooo
  125.  
  126. Class ourclass = Class.forName("com.example.apaooo."+positn);
  127.  
  128. Class ourclass = Class.forName("com.example.list" + positn);
  129.  
  130. Class ourclass = Class.forName("com.example.apaooo." + positn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement