我试图为我的 Fragment 实现 DragListener,但应用程序崩溃并在此行上给我一个 NoClassDefFoundError:
findViewById(R.id.my_tab_fragment).setOnDragListener(new MyDragListener());
这是我的片段:
public class MainFragmentActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle bundle) {
WWHApplication.getInstance().getJsonDBInstance();
WWHApplication.checkDB();
super.onCreate(bundle);
setContentView(R.layout.main_fragment_activity_drag);
findViewById(R.id.my_tab_fragment).setOnDragListener(new MyDragListener());
}
class MyDragListener implements OnDragListener {
//Drawable enterShape = getResources().getDrawable(
// R.drawable.shape_droptarget);
//Drawable normalShape = getResources().getDrawable(R.drawable.shape);
@Override
public boolean onDrag(View v, DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// Do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
//v.setBackgroundDrawable(enterShape);
break;
case DragEvent.ACTION_DRAG_EXITED:
//v.setBackgroundDrawable(normalShape);
break;
case DragEvent.ACTION_DROP:
// Dropped, reassign View to ViewGroup
//View view = (View) event.getLocalState();
//ViewGroup owner = (ViewGroup) view.getParent();
//owner.removeView(view);
//LinearLayout container = (LinearLayout) v;
//container.addView(view);
//view.setVisibility(View.VISIBLE);
break;
case DragEvent.ACTION_DRAG_ENDED:
//v.setBackgroundDrawable(normalShape);
default:
break;
}
return true;
}
}
}
我需要做什么来修复错误?谢谢