0
ドラッグドロップ機能を含むゲームを開発しています。 Samsung Galaxy S6を除くすべてのデバイスで動作します。ViewRootImpl:Dropの結果を報告する:Samsung Galaxy S6のfalse
class MyDragListener implements View.OnDragListener {
Drawable normalShape = getResources().getDrawable(R.drawable.normal_shape);
Drawable targetShape = getResources().getDrawable(R.drawable.target_shape);
@Override
public boolean onDrag(View v, DragEvent event) {
// Handles each of the expected events
switch (event.getAction()) {
//signal for the start of a drag and drop operation.
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
//the drag point has entered the bounding box of the View
case DragEvent.ACTION_DRAG_ENTERED:
//v.setBackground(targetShape); //change the shape of the view
break;
//the user has moved the drag shadow outside the bounding box of the View
case DragEvent.ACTION_DRAG_EXITED:
break;
//drag shadow has been released,the drag point is within the bounding box of the View
case DragEvent.ACTION_DROP:
View view = (View) event.getLocalState();
// There is some code here
break;
//the drag and drop operation has concluded.
case DragEvent.ACTION_DRAG_ENDED:
//v.setBackground(normalShape); //go back to normal shape
default:
break;
}
return true;
}
}
class MyClickListener implements View.OnTouchListener {
@Override
public boolean onTouch(View view, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// create it from the object's tag
ClipData.Item item = new ClipData.Item((CharSequence) view.getTag());
String[] mimeTypes = {ClipDescription.MIMETYPE_TEXT_PLAIN};
ClipData data = new ClipData(view.getTag().toString(), mimeTypes, item);
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, //data to be dragged
shadowBuilder, //drag shadow
view, //local data about the drag and drop operation
0 //no needed flags
);
view.setVisibility(View.INVISIBLE);
return true;
}
else if (event.getAction() == MotionEvent.ACTION_UP){
view.setVisibility(View.VISIBLE);
return true;
}
else
{
return false;
}
}
}
ビルド階調は次のようになります。
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "________"
minSdkVersion 16
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
debuggable false
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:appcompat-v7:23.1.0'
}
サムスンギャラクシーS6(Androidバージョン5.1.1)のドラッグアンドドロップ後、画像が消えるだけです。コンソールに表示されるエラーはです。ViewRootImpl:報告結果の削除:falseこのアプリはほかのデバイスに問題ありません。それはAPIの問題なのでしょうか?あなたの情報については、私はこれを確認したsolutionしかし、これは私の問題を解決できませんでした。
if (!isDropped) {
((View) dragEvent.getLocalState()).setVisibility(View.VISIBLE);
}
をisDropped
がfalse
として宣言されたグローバルboolean
変数であるあなたのonDrag(...)
方法、の終わりに、しかし、あなたのACTION_DROP
ケースの内側にそれがtrue
に等しい作る:私は追加することをお勧め消えるから画像を防止するために