Android Question Widget on screen

dibesw

Active Member
Licensed User
Longtime User
HI,
is there a event when I drag and drop the widget on screen?
If yes, which is?
 

dibesw

Active Member
Licensed User
Longtime User
I did a bid of testing and I think it's a issue.
When I drag the widget from list of widgets, the event of widget service that fired are
CREATE
START
rv_RequestUpdate (where rv is RemoteViews)
Note that I do only "drag" and not yet "drop"
I saw that there are many apps that exec anything after "drop"
it is possible that nothing can be done?
also because the app has to do something only
after the user has done the "drop" on screen
 
Upvote 0

dibesw

Active Member
Licensed User
Longtime User
I have found this.
The event should be "ACTION_DROP" but I do not know how to do it in b4a

B4X:
hostView.setOnDragListener(new OnDragListener() {
         Drawable enterShape = getResources().getDrawable(R.drawable.shape_droptarget);
            Drawable normalShape = getResources().getDrawable(R.drawable.shape);
        @Override
        public boolean onDrag(View v, DragEvent event) {
             int action = event.getAction();
              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);
                GridLayout container = (GridLayout) v;
                container.addView(view);
                view.setVisibility(View.VISIBLE);
                break;
              case DragEvent.ACTION_DRAG_ENDED:
                v.setBackgroundDrawable(normalShape);
              default:
                break;
              }
              return true;
        }
    });
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…