Tag: android-fragments

Fragment from View Pager hiding behind Tab Bar

I am having an issue with a Tab bar and ViewPager in my android project. What the app does it has an activity which hosts a tab layout and then has 2 fragment which represents each of the tabs. When the activity is opened it posts to an API to get some data and puts […]

How to move from one fragment to another fragment on click of a ImageView in Android?

I have an ImageView. I want to move from one fragment to another fragment on a click of an Imageview, the same way like we can move from one activity to another using Intent i=new Intent(MainActivity.this,SecondActivity.class); startActivity(i); How can I do this? Can anyone explain to me step by step? My codes are as follows: […]

Swiping to the next Fragment with a button click

Please have a look at the following code. FirstView.java import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class FirstView extends Fragment { private TextView firstText; private Button btn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view1,container,false); firstText = (TextView)view.findViewById(R.id.viewOneText); […]

Programmatically change color of shape in layer list

How can I programmatically change the color (#000000) of a shape in a layer list? Here is my layer list: <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item> <shape android:shape=”rectangle”> <solid android:color=”#000000″ /> // CHANGE THIS COLOR </shape> </item> <item android:left=”5dp”> <shape android:shape=”rectangle”> <solid android:color=”@color/bg” /> </shape> </item> </layer-list>

Android set edit text style globally in theme doesn't work

I am facing with problem. I am trying to make edit texts in my app look the same with the help of theme. I have generated styles with the help of online tools (9-patch images) and tried to set it in my theme like this <!– Base application theme. –> <style name=”DefaultAppTheme” parent=”Theme.AppCompat”> <!– Main […]

Android : Accessing container activity object from fragment using putExtra?

I am building a tab interface using Action bar and fragment. I would need assistance in sending data from container activity to the fragment. To elaborate, I have job object in container activty. And I have created few tabs based on the information in job object (like company details, experience details etc). I need to […]

Intent from Fragment to Activity

I was trying to go to another page using button, but it always fail. Here is my First Class with its XML: public class FindPeopleFragment extends Fragment { public FindPeopleFragment(){} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_home, container, false); return rootView; } public void goToAttract(View v) { Intent […]

How background changes at login in Instagram app?

I have made my app to change background color every few milliseconds. But it is not appealing to user. If you have seen Instagram’s login screen, it changes color at a very soft rate and with blurry effect. I just wanted that type of background for my app. What should I have to do for […]

How to switch tabs programatically in android from fragment?

I have implemented a TabActivity which extends FragmentActivity. It has 5 tabs each tab is a Fragment. What i am looking for is to switch between the tabs programmatically. For eg: if i am in tab4. On button click I want to move from tab4 to tab1. Tried a lot but couldn’t find the solution […]

menu inflating calls multiple times at fragment's onCreateOptionsMenu

I use Fragments and when I switch to nested Fragment, which implements public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) my menu inflates quantity of times when I get to that nested Fragment. How can I avoid this? I also implement constructor of Fragment with methods: setRetainInstance(true); setHasOptionsMenu(true); When I tried to implement siple solution as: @Override […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.