Apply Button background color dynamically Android
Posted onhttp://stackoverflow.com/questions/10295442/how-to-apply-button-background-color-dynamically-using-color-resources-in-color
http://stackoverflow.com/questions/10295442/how-to-apply-button-background-color-dynamically-using-color-resources-in-color
Google Map Direction request API changed It seems Google Map Direction request API changed, which is used to get polyline points to draw drive path. Previously, I implemented drawing driving path on Map using below directions request. And this link worked perfectly, I used to get all the waypoints information, with it. https://maps.googleapis.com/maps/api/directions/json? waypoints=optimize:true|52.28582710000001,-1.1141665|52.2777244,-1.1581097& sensor=false but […]
Display Menu items in Fragment ActionBar When Implementing Fragment screen, If it require to display Menu Items only specific to that Fragment screen. If you just write the following code… @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Auto-generated method stub super.onCreateOptionsMenu(menu, inflater); menu.clear(); inflater.inflate(R.menu.done_actions_menu, menu); } /** * On selecting action bar icons […]
After importing project from eclipse into Android Studio i have got the following error Unmappable character for encoding UTF-8 Error: unmappable character for encoding UTF-8 Solution for Unmappable character for encoding To fix this issue, in Android Studio, Open the File with the encoding issue. Go to File menu-> Select File Encoding ->You’ll see a […]
Default Validation EditText I found a good article here on how to use the default feature of EditText to show the error. While writing the validation on EditText on a button click event or TextChanged event instead of showing alert dialog if you want to show error we can use the default feature of EditText as EditText […]
Applying Dialog Style to Activity Generally when we set Activity theme as dialog style, <activity android:label=”@string/app_name” android:name=”.DialogActivity” android:theme=”@android:style/Theme.Dialog” /> <activity/> its just display at the center of the screen, with specific width and height set in the XML Layout file or as per the Content. as shown below. At times you may want to display […]
Validate a URL / Website To validate URL/ Website name entered in a EditText, this following works fine… private boolean isValidUrl(String url) { Pattern p = Patterns.WEB_URL; Matcher m = p.matcher(url.toLowerCase()); if(m.matches()) return true; else return false; } URL should be in lowercase to validate correctly. Here is ref link. Hope this helps somebody… Cheers…
At times you may need to set Space between columns and rows for in GridView. Set following attributes of GridView To set space between rows android:verticalSpacing=”2dp” To set space between columns android:horizontalSpacing=”2dp” Sample screeshot.. Cheers.. You may be also interested in Simple Weekview calendar implemented using GridView ScrollView auto scroll to show content in app […]
DatePickerDialog While working with DatePickerDialog, I see an issue when setting a date and click done button. Its calling onDateSet method two times. here is a simple solution for it. DatePicker parameter object has a method called isShown(). Place method statements in the if condition of isShown(), which avoids calling onDateSet method statements two times. @Override […]
Show Spinner Dropdown items To show Spinner dropdown items, when click on a button, as shown in image below spinnerView.performClick(); ex: btnView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { spinnerView.performClick(); } }); Hope it helps somebody Cheers …