起初:我知道onDrag并且onLongClick仅在 API 11(android 3.0) 或更高版本上可用。
类实现onDragListener和onLonglickListener. 它仅适用于 API 11 及更高版本。当我想设置setonLongclickListener时,view我使用这样的代码:
.....
protected static final int sdk = android.os.Build.VERSION.SDK_INT;
......
......
if(sdk >= 11){
for (int i = 0; i < LlayoutFront.getChildCount(); i++){
LlayoutFront.getChildAt(i).setOnDragListener(this);
}
LlayoutDeleteArea.setOnDragListener(this);
LlayoutSetupArea.setOnDragListener(this);
findViewById(R.id.RelativeLMain).setOnDragListener(this);
}
但是当我尝试运行它时应用程序崩溃了android 2.1。
@SuppressLint("NewApi")在我的课没有挽救我的情况之前。
有任何想法吗?