嗨,我班上有两个 listArrays。我想在活动类中使用一个类,但我想将两者都放在一个arrayList 中,该arrayList 存在于我所有应用程序中定义的公共类中。数据名称是 Data 我的第一个类包含下一个数组:
//Class1
public static ArrayList<String> array1=new ArrayList<String>();
public static ArrayList<String> array2=new ArrayList<String>();
//Data
public static ArrayList<Class1> getE = new ArrayList<Class1>();
好吧,我尝试在 Activity 类中使用 class1 中的 obj 从 listArray 中获取值,但是应用程序在运行时崩溃了。这就是为什么我想将数组的值放入 Data 类中的一个数组中。接下来我展示了我是如何使用这个对象的:
//ActivityClass
Class1 c1=new Class1();
if(c1.array1.get(1)=="1")
{
return ;
}
第一个问题:如何将array1和array2中的值放入Data类getE中的数组中??
第二问:为什么我在ActivityClass中使用obj时app崩溃了?
09-25 07:03:04.888: E/UNIVERSITY(645): Size of List Before 0
09-25 07:03:06.948: I/dalvikvm(645): threadid=3: reacting to signal 3
09-25 07:06:54.738: E/AndroidRuntime(645): FATAL EXCEPTION: main
09-25 07:06:54.738: E/AndroidRuntime(645): java.lang.NullPointerException
09-25 07:06:54.738: E/AndroidRuntime(645): at com.university.app.PersonalHome$1.onItemClick(PersonalHome.java:61)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.university.app.controls.CarouselAdapter.performItemClick(CarouselAdapter.java:261)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.university.app.controls.Carousel.onSingleTapUp(Carousel.java:964)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:568)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.university.app.controls.Carousel.onTouchEvent(Carousel.java:310)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.View.dispatchTouchEvent(View.java:5541)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1951)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1712)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1912)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1860)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.View.dispatchPointerEvent(View.java:5721)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.os.Looper.loop(Looper.java:137)
09-25 07:06:54.738: E/AndroidRuntime(645): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-25 07:06:54.738: E/AndroidRuntime(645): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 07:06:54.738: E/AndroidRuntime(645): at java.lang.reflect.Method.invoke(Method.java:511)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-25 07:06:54.738: E/AndroidRuntime(645): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-25 07:06:54.738: E/AndroidRuntime(645): at dalvik.system.NativeStart.main(Native Method)
09-25 07:18:01.538: E/AndroidRuntime(715): at java.lang.reflect.Method.invoke(Method.java:511)