我正在测试我的应用程序第一个在Android设备(galaxy s3 mini)上已经在模拟器中多次测试过。该应用程序包含自定义列表视图(DynamicListView:http://www.youtube.com/watch?v=_BZIvjMgH-Q)。可以在此处找到此类带有演示应用的代码http://developer.android.com/shareables/devbytes/ListViewDraggingAnimation.zip
扩展列表视图类与我的主要活动位于同一个包中,并添加到主活动布局中,但在安装应用程序并即将启动logcat打印后,无法找到该类。我在网上搜索过,似乎找不到解决方案,甚至没有找到类似问题的人。我对这个问题感到困惑,因为我真的不知道如何解决这个问题,并希望得到任何帮助。
早期记录以下内容......
10-07 08:35:20.627: E/dalvikvm(16558): Could not find class 'com.amanda.tiara.DynamicListView$2', referenced from method com.amanda.tiara.DynamicListView.<clinit>
稍后......(注意最后两行)
10-07 08:32:39.443: E/AndroidRuntime(15341): FATAL EXCEPTION: main
10-07 08:32:39.443: E/AndroidRuntime(15341): java.lang.ExceptionInInitializerError
10-07 08:32:39.443: E/AndroidRuntime(15341): at java.lang.Class.getDeclaredConstructors(Native Method)
10-07 08:32:39.443: E/AndroidRuntime(15341): at java.lang.Class.getConstructor(Class.java:503)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.view.LayoutInflater.createView(LayoutInflater.java:511)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:601)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.view.LayoutInflater.rInflate(LayoutInflater.java:654)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.view.LayoutInflater.inflate(LayoutInflater.java:439)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.view.LayoutInflater.inflate(LayoutInflater.java:351)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.view.LayoutInflater.inflate(LayoutInflater.java:307)
10-07 08:32:39.443: E/AndroidRuntime(15341): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.Activity.setContentView(Activity.java:1694)
10-07 08:32:39.443: E/AndroidRuntime(15341): at com.amanda.tiara.MainActivity.onCreate(MainActivity.java:40)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1699)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1754)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.ActivityThread.access$1500(ActivityThread.java:156)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1000)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.os.Handler.dispatchMessage(Handler.java:130)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.os.Looper.loop(SourceFile:351)
10-07 08:32:39.443: E/AndroidRuntime(15341): at android.app.ActivityThread.main(ActivityThread.java:3821)
10-07 08:32:39.443: E/AndroidRuntime(15341): at java.lang.reflect.Method.invokeNative(Native Method)
10-07 08:32:39.443: E/AndroidRuntime(15341): at java.lang.reflect.Method.invoke(Method.java:538)
10-07 08:32:39.443: E/AndroidRuntime(15341): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
10-07 08:32:39.443: E/AndroidRuntime(15341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
10-07 08:32:39.443: E/AndroidRuntime(15341): at dalvik.system.NativeStart.main(Native Method)
10-07 08:32:39.443: E/AndroidRuntime(15341): Caused by: java.lang.NoClassDefFoundError: com.amanda.tiara.DynamicListView$2
10-07 08:32:39.443: E/AndroidRuntime(15341): at com.amanda.tiara.DynamicListView.<clinit>(DynamicListView.java:517)
10-07 08:32:39.443: E/AndroidRuntime(15341): ... 24 more
修改
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
lv = (DynamicListView)findViewById(R.id.mylist);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
DialogFragment ActionOptions = new ActionOptions();
ActionOptions.show(getSupportFragmentManager(), "actions_options");
}
});
lst = new ArrayList<AnActivity>();
adp = new ActivityAdapter(this,lst);
lv.mActivities = lst;
lv.setAdapter(adp);
adp.lv = lv; //Adding internal reference for listview
calc = (Button)findViewById(R.id.Calc);
calc.setOnClickListener(new OnClickListener(){
public void onClick(View v){
DateTime begin = new DateTime();
for (int i = 0; i < lst.size(); i++){
lst.get(i).startTime = begin;
begin = begin.plusHours(lst.get(i).duration.hours);
begin = begin.plusMinutes(lst.get(i).duration.minutes);
}
adp.notifyDataSetChanged();
}
});
start_pause = (Button)findViewById(R.id.start_pause);
start_pause.setOnClickListener(new OnClickListener(){
public void onClick(View v){
if (running)
adp.pause();
else
adp.go();
running = !running;
}
});
Button list_actions = (Button) findViewById(R.id.list_actions);
list_actions.setOnClickListener(new OnClickListener(){
public void onClick(View v){
showEditDialog();
}});
}
修改2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.amanda.tiara.DynamicListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="3dp" >
<TextView
android:id="@+id/Schedule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="Calibri"
android:text="Schedule"
android:textSize="32dp" >
</TextView>
<Button
android:id="@+id/list_actions"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add" />
<Button
android:id="@+id/start_pause"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start/Stop" />
<Button
android:id="@+id/Calc"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="C" />
</LinearLayout>
<com.appfactory.timemania.DynamicListView
android:id="@+id/mylist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:paddingTop="10dp" />