代码编译没有错误。但是代码运行时我的手机正在重置。 我使用DragDrop.class对主页“ Blue.Class”对象进行编码,以操作并获取该函数。 DragDrop.class具有静态功能。因此,在运行代码时出现错误。正常页面上使用相同的代码。 DragDrop页面没有接口xml,仅由代码组成。我的主要目标是播放音乐,但如果消息在音乐中起作用。
public class DragDrop extends Application {
public static boolean sonuc=false;
public static ImageView suruklenen;
private static Context context;
public void onCreate() {
super.onCreate();
}
public void DragDrop()
{
DragDrop.context=getApplicationContext();
mavi aaa=new mavi();
aaa.musical();
}
public static Context getAppContext()
{
return DragDrop.context;
}
public static final class MyClickListener implements View.OnTouchListener {
@Override
public boolean onTouch (View v, MotionEvent event) {
ClipData.Item item = new ClipData.Item((CharSequence)v.getTag());
String[] mimeTypes = { ClipDescription.MIMETYPE_TEXT_PLAIN };
ClipData data = new ClipData(v.getTag().toString(), mimeTypes, item);
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
v.startDrag( data, //data to be dragged
shadowBuilder, //drag shadow
v, //local data about the drag and drop operation
1); //no needed flags
System.out.println("Suruklenen id ne : "+v.getResources().getResourceName(v.getId()));
suruklenen= (ImageView) v;
System.out.println("Saklanan id ne : "+suruklenen.getResources().getResourceName(suruklenen.getId()));
v.setVisibility(View.VISIBLE);
Toast.makeText(getAppContext(), "Demo mesage but not working", Toast.LENGTH_SHORT).show();
return false;
}
}