How to implement a ViewPager with different Fragments / Layouts

When I start an activity which implements viewpager, the viewpager created various fragments. I want to use different layouts for each fragment, but the problem is that viewpager shows only two layouts at the max (second layout on all of the remaining fragments after 1). Here is the code for SwipeActivity which implements the viewpager … Read more

Android Spinner : Avoid onItemSelected calls during initialization

I created an Android application with a Spinner and a TextView. I want to display the selected item from the Spinner’s drop down list in the TextView. I implemented the Spinner in the onCreate method so when I’m running the program, it shows a value in the TextView (before selecting an item from the drop … Read more

How to adjust layout when soft keyboard appears

I would like to adjust/re-size the layout when the soft-keyboard activated, as below: Before and After: Found couple resources in SO: How to keep all fields and texts visible while the soft keyboard is shown android soft keyboard spoils layout when appears Adjust layout when soft keyboard is on But the questions & answers are … Read more

How to display count of notifications in app launcher icon [duplicate]

This question already has answers here: Is there a way to add a badge to an application icon in Android? (6 answers) Closed 4 years ago. samsung galaxy note 2 android version 4.1.2 I know that this question was asked before and the reply was not possible How to display balloon counter over application launcher … Read more

Getting activity from context in android

This one has me stumped. I need to call an activity method from within a custom layout class. The problem with this is that I don’t know how to access the activity from within the layout. ProfileView public class ProfileView extends LinearLayout { TextView profileTitleTextView; ImageView profileScreenImageButton; boolean isEmpty; ProfileData data; String name; public ProfileView(Context … Read more

How can I change default dialog button text color in android 5

I have many alert dialogs in my app. It is a default layout but I am adding positive and negative buttons to the dialog. So the buttons get the default text color of Android 5 (green). I tried to changed it without success. Any idea how to change that text color? My Custom dialog: public … Read more