OnTouchListener intercept when touch goes outside view
Here is a View.OnTouchListener that you can use to see if MotionEvent.ACTION_UP was sent while the user had his/her finger outside of the view:
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 21 of 231 answers tagged android
Exported May 9, 2026
Here is a View.OnTouchListener that you can use to see if MotionEvent.ACTION_UP was sent while the user had his/her finger outside of the view:
ViewGroup extends View which does not implement Serializable . So, this is impossible.
Since you have a ListView in the same layout, you should avoid adding a ScrollView as others have suggested. I would put the attributes in styles for each "panel" to remove redundant code. I would then add your layout...
How can I call this following method in above java file? In onCreateView(LayoutInflater, ViewGroup, Bundle) you can still use findViewById(int) . The following will call the constructor you want:
I am assuming you copied your code from this StackOverflow answer . numberPickerStyle would be an attribute that is defined in your app. The code that you copied from the answer does not work. You would need to define...
You should pass the context to the constructor or method you are calling. Edit: Just for fun, you can actually get the application context in a static way. This is not recommended:
The appcompat themes remove the native ActionBar and use the support ActionBar. You need to change To You also need to change Base.Theme.AppCompat.Light to Theme.AppCompat.Light in your AndroidManifest. Please see this...
You will not be able to use the pm command with your application UID; you need to be root (0) or shell (2000). This may be why you are getting a permission denied error. I successfully set the installer package name...
As mentioned in the comments, there are many answers to this question. Just for fun I wrote my own method real quick. Feel free to use it and/or improve it: Test: Output:
The problem: One (or all) of your EditText s is not a valid integer and is failing on Integer.parseInt(String) . You should handle any NumberFormatException and check the value of your EditText s (feet, inches, lbs)....
You need root access to do this. It would be a huge security issue otherwise. You can use a library like libsuperuser to run root commands. Example using libsuperuser:
If you post some code it would be helpful. However, having had issues with this in the past I know using postDelayed usually fixes it:
Open up android.jar and navigate to com.android. You will notice the package com.android.dx is omitted. Edit: You should be able to add dx.jar as a dependency. It should be located in...
For something that simple I don't think adding Gson as a dependency is worth it. Example:
I would look into storing the data into a SQLiteDatabase . SharedPreferences wasn't intended to save custom objects. If you really want to use SharedPreferences then Gson will be the best solution. API 11 added the...
Please see Linking to Your Products . Most likely, you are using the website URL. Try the following intent below: You should also check if com.android.vending is installed before starting that intent.
I wrote this class to help with SearchView customization: https://gist.github.com/jaredrummler/c408c9d897fd92d5d116 You could do something like this after inflating the menu in onCreateOptionsMenu :
Something like this should work. Change file to whatever you want.
This should work: isExternalStorageRemovable() isExternalStorageEmulated()
This is always the best approach: You could also get the environmental variable which is on all Android devices like this: