Posts

Showing posts from August, 2017

On focus out Keyboard hiding issue : after hiding keyBoard when I click in EditText it crashed

I am working on to hide keyboard when click out side the EditText. At first I set OnTouch listender & Click listener out site EditText elements. When those elements touched I am calling a custom method ( hideKeyBoard() show below ). private void hideKeyBoard() { InputMethodManager imm = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE ); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0 ); } and additionally I have to add those competent few attribute like android :clickable= "true" android :focusable= "true" android :focusableInTouchMode= "true" to make those elements clickable & focusable. keyBoard was hiding & when I click EditText again I get error : Caused by:  java . lang . NullPointerException : Attempt  to  invoke virtual method  ' android . os . IBinder android . view . View . getWindowToken()'  on a  null object reference solution : after implementing th

Android Date picker dialog setMinDate(long) and setMaxDate(long) issue

My objective was enable date with in certain range & disable the rest for date , so that user can't select those dates. I find these two method for date picker to set the minimum & maximum range. so first I able to disable all future dates with : d.getDatePicker().setMaxDate(System.currentTimeMillis()); this was working fine. Than I disable all dates before two weeks ago with this code : d.getDatePicker().setMaxDate(System.currentTimeMillis() - (2*7*24*60*60*1000)); it was working fine. here 2 for weeks, 7 for days, 24 for hour, 60 for minutes, 60 for seconds & 1000 for millisecond. so from last two weeks to current date my code was like this d.getDatePicker().setMaxDate(System.currentTimeMillis() - (2*7*24*60*60*1000)); d.getDatePicker().setMaxDate(System.currentTimeMillis()); The problem was when i desire to set range earlier this month. this process was not working. As an example i was planning to set date range between 42 weeks to 9 weeks early. t

how to hide Fragment element from another fragment in Android - issue android

I wanted to hide component of a Fragment from another Fragment. I am using ViewPager for  Fragments. previously I transfer data from one Fragment to another Fragment, that time I before FragmentTransaction replace I added Bundle to ListDetailsFragment. so that was pretty easy stuff. i use FrameLayout Fragments. And it this case ViewPager is in place. I was able to pass data to Activity with interface, but unable to update date as fragment is already created. looking Fragment life cycle I was hopeful that onStart() will help me to update data when that particular Fragment is displayed. But I was wrong due to ViewPager  in place. than I have my answer in https://stackoverflow.com/questions/18375288/fragment-lifecycle-which-method-is-called-upon-show-hide. Here is the solution code I am come out with. [Objective selecting Hide / Show radio button in  FragmentOne, I will  Hide / Show text in  FragmentTwo ] ...........................................................................