I am attempting to run commonsguy’s MergeAdapterDemo. The code compiles and runs fine when i comment out the calls to addView. For example, this runs fine:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
adapter=new MergeAdapter();
arrayAdapter=buildFirstList();
adapter.addAdapter(arrayAdapter);
//adapter.addView(buildButton(), true);
adapter.addAdapter(buildSecondList());
//adapter.addView(buildLabel());
adapter.addAdapter(buildSecondList());
However, this will crash:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
adapter=new MergeAdapter();
arrayAdapter=buildFirstList();
adapter.addAdapter(arrayAdapter);
adapter.addView(buildButton(), true);
adapter.addAdapter(buildSecondList());
adapter.addView(buildLabel());
adapter.addAdapter(buildSecondList());
Here is the callstack when the crash occurs:
Thread [<1> main] (Suspended (exception NoClassDefFoundError))
MergeAdapter.addViews(List, boolean) line: 101
MergeAdapter.addView(View, boolean) line: 78
MergeAdapter.addView(View) line: 64
MergeAdapterDemo.onCreate(Bundle) line: 52
Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1047
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1611
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1663
ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 117
ActivityThread$H.handleMessage(Message) line: 931
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3683
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 839
ZygoteInit.main(String[]) line: 597
NativeStart.main(String[]) line: not available [native method]
I am using the prebuilt .jar file that was located in the download section of his page.
Any suggestions on how to get this working? Thanks!
Line 101 is
But you don’t have
SackOfViewsAdapterclass.https://github.com/commonsguy/cwac-merge/blob/master/README.markdown says that:
So you need to include that library in your project as well.