user-interaction

How to create a resizable rectangle with user touch events on Android?

好久不见. 提交于 2019-12-17 02:42:09
问题 I want to create a rectangular shape that will be resized with the touches of the user. Below image is a good example of what i want to do: Is there any example like that? What do I need to study to implement this? Thanks in advance, 回答1: To implement a custom view, you derive a class from View :) Override onDraw() for looks, override onTouchEvent() for input processing. Note that in Android, you cannot draw on view outside onDraw() ; if you want to refresh the view, call invalidate() . You

How to create a resizable rectangle with user touch events on Android?

核能气质少年 提交于 2019-12-17 02:42:08
问题 I want to create a rectangular shape that will be resized with the touches of the user. Below image is a good example of what i want to do: Is there any example like that? What do I need to study to implement this? Thanks in advance, 回答1: To implement a custom view, you derive a class from View :) Override onDraw() for looks, override onTouchEvent() for input processing. Note that in Android, you cannot draw on view outside onDraw() ; if you want to refresh the view, call invalidate() . You

How to detect swipe direction between left/right and up/down

牧云@^-^@ 提交于 2019-12-17 01:40:42
问题 My Question: How do I detect when a user moves their finger up/down vs left/right (and how do I know which direction of those groups their finger moved)? My Situation: I want to change the brightness of my app when they move their finger up and down (up = brighter, down = darker), and I want to switch between activities and/or views based on their left/right swipe. 回答1: You simply have to extend SimpleOnGestureListener class, Declare this in your class, private static final int SWIPE_MIN

UIButton not clickable when custom view called

落花浮王杯 提交于 2019-12-14 03:48:00
问题 I am new to iPhone development,I need help in understanding the below,as I am able to create newView using the following UIView *newView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 30)]; newView.backgroundColor=[UIColor clearColor]; UIButton *newViewBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; newViewBtn.frame = CGRectMake(newView.frame.origin.x+5, newView.frame.origin.y+5,60,20); [newView addSubview:newViewBtn]; [self.view addSubview:newView]; Above code is working without

How do I detect user inactivity in Swift? [duplicate]

南楼画角 提交于 2019-12-14 03:38:08
问题 This question already has answers here : How to detect user inactivity since last touch on a particular viewcontroller in iOS? (2 answers) Closed 4 years ago . I need to implement an Idle Time Out feature. To do that I simply need to know how to detect when the user touches the screen (something similar to onUserInteraction method used in Android). So how can I simply discover when the user interacts with the ViewController? P.S: if I ask this it is because you can't find nothing good in the

When exactly is onUserInteraction() called?

陌路散爱 提交于 2019-12-13 13:14:52
问题 in my app I got a thrad that checks every 60s data from a webservice (defined in onCreate()): new Thread(new Runnable() { @Override public void run() { while (true) { try { Thread.sleep(PERIOD); if(condition) do_something(); } catch (Exception e) { e.printStackTrace(); } } } }).start(); Additionally i got a handler executing a method after a period of user inactivity: private Handler disconnectHandler = new Handler(); private Runnable disconnectCallback = new Runnable() { @Override public

Show Action Bar when user does not interact for some time in Android

女生的网名这么多〃 提交于 2019-12-13 05:34:56
问题 Hi in my android app I would like to hide the action bar on user interaction and show it again when the user has stopped interacting for some time. Now I already have the code for hiding the action bar: mViewPager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub getActionBar().hide(); return false; } }); I simply added an onTouchListener to my main view But I do not know how to implement the

change color of UITableViewCell after reenabled userinteraction

不想你离开。 提交于 2019-12-13 04:31:18
问题 in my app, i've some menupoints, that are disabled for userinteraction. cell.userInteractionEnabled = FALSE; after the login, i want to reenable some of these cells. this snippet is working half the way: NSIndexPath *editUsersPath = [NSIndexPath indexPathForRow:0 inSection:1]; [self.tableView cellForRowAtIndexPath:importPath].userInteractionEnabled = YES; [self.tableView cellForRowAtIndexPath:importPath].accessoryType = UITableViewCellAccessoryDisclosureIndicator; [self.tableView

SWRevealViewController: Remove interaction on frontview when rearview is revealed

久未见 提交于 2019-12-12 07:09:14
问题 I need to disable user interaction on front view when rear view is revealed. Found some others asking the same thing but can't really understand where or how to implement the code that I've seen. Ex: I found this code from link, - (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position { if(position == FrontViewPositionLeft) { self.view.userInteractionEnabled = YES; } else { self.view.userInteractionEnabled = NO; } } - (void

Disable zoom in a UIWebView but keep other user interaction

纵饮孤独 提交于 2019-12-11 08:31:49
问题 I have a UIWebView that shows some text, I want to disable zoom/unzoom but I want to detect when users tap on a link. I have tried with disabling MultiTouch but zoom is still working. 回答1: Setting the minimumZoomScale and maximumZoomScale on your webview's UIScrollView to be 1.0 should prevent the webview from zooming. webview.scrollView.maximumZoomScale = 1.0; webview.scrollView.minimumZoomScale = 1.0; 回答2: Try this - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return