Posts

Showing posts from September, 2013

Android how to listen ListView scrolling offset problem

Today I wanted to implement the UI looks like Google plus app in both Android and IOS. One thing came out is that ListView and bottom menu. From Google Plus that bottom menu will slidedown when User scrolling the listview down and slideup when user scrolling the listview up. So the question is how to listen the listview scrolling up and down. First , there is no this api to listen how much listview scrolled by. Second, I tried the onInterceptTouchEvent in my customized ListView. It only works at first several touchevents. Then I checked the source codes of ListView and AbsListView. in function : private boolean startScrollIfNeeded ( int y ){ ... if ( overscroll || distance > mTouchSlop ) { ... if ( parent != null ) { parent . requestDisallowInterceptTouchEvent ( true ); } ... } ... } ok, thats why our interception not work anymore after the scrolling offset bigger than

Android Trick - Pick photo from Gallery and 3rd party app

In Android we can using Intent to share data between applications. Simple usage for this part is Picking images or photos from the other applications. Normally the codes is like the following: private void pickPhotoFromGallery() {     Intent intent = new Intent();     intent.setType( "image/*" );     intent.setAction(Intent.ACTION_PICK);     //following line code will specify the dialog title of choosing different content source app     startActivityForResult(Intent.createChooser(intent, "Complete action using" ),SELECT_PHOTO ); } Noticed that if I set Intent Action as Intent.ACTION_PICK it will only select images from System Gallery App. if I called  intent.setAction(Intent. ACTION_GET_CONTENT );  It will get from the other apps. And the result is not same. From Gallery app the uri format is like : content://xxx/xx/xx but the other app will return uri like : file:///xxx/xx/xx Actually the Gallery app returned is n