Tag: android-fragments

Fragment content is overlaying Toolbar

I recently started messing around with the new components of AppCompat 21 and implementing Material Design. Currently, I have an ActionBarActivity with a Toolbar and am trying to have it host a fragment containing a RecyclerView of TextView items (just to test out Recycler). I have items being displayed, but the text in each view […]

Access the ActionBar from within a Fragment

How do you access the ActionBar from within a Fragment (android.support.v4.app.Fragment). I am using the Android Support Library v4 and v7. I’m not using the Sherlock library’s. The activity hosting the fragment is an ActionBarActivity. I have read the Android help section Fragment which led me too getActivity() but there is no getSupportActionBar() method. ActionBar […]

Android Studio – Illegal character 8204 error

For some reason, after rebuilding my project I get an illegal character error but nothing within my code gets underlined in red. Can someone please tell me what is wrong and how to resolve it? Error illegal character: \8204 WCBankActivity.java import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBarActivity; public class WCBankActivity extends ActionBarActivity { public […]

Why is my fragment onCreate being called extensively whenever I page through my applications viewPager?

I’m not quite understanding this fragment lifecycle business. I have a pretty standard 3 page horizontal slider view Pager layout for a “view details” section of my app. I start my app on the middle page of the three. My FragmentActivity sets the page to page 1. mPager.setCurrentItem(1); //default to center page, current data view […]

listfragment simple example

Hello i want to get simple list fragment example i have searched out but could not get it so please can any body help me import android.support.v4.app.Fragment; i have searched out but mostly in import android.app.*; so any body help me to find out example so it is not working on my android 2.2 if […]

getActionBar from Fragment with AppCompatLibrary

I’m look for the easiest way to get an ActionBar instance from a Fragment using AppCompatLibrary and API 8. Already tried things like getActivity().getSupportActionBar() but no luck.

How to pass a value from one Fragment to another in Android?

I am a newbie to Fragments. I want to pass a String value from one Fragment to another. how to do this? I have called my Fragments in the following way. please guide me step by step. String cid = id.getText().toString(); Fragment fr = new FriendFragment(); android.app.FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.content_frame, fr); ft.commit();

How to Remove Fragment from FragmentPagerAdapter?

I know there are some topics about this here already but I could not find a solution which I could get to work for my case. I have a working sliding gallery using a custom FragmentActivity and FragmentPagerAdapter which holds a list of Fragments. Within the FragmentActivity is a ImageView “delete”. If clicked the function […]

Change viewpager fragment by a buttonClick

I’m trying to change the viewpager fragment by clicking on a button. I have 5 fragments, each fragment has it’s own xml file (frag1.xml, frag2.xml, and so on). Every fragment has it’s 5 buttons that should go to other pages of the viewpager. But the problem is how do I check in the FragmentPageAdapter which […]

Adding PlaceAutocompleteFragment to fragment throws error

I have implemented PlaceAutocompleteFragment in activity and is working successfuly. But how to implement the same in fragment in android? I have implemented placeautocomplete fragment like this PlaceAutocompleteFragment autocompleteFragment1 = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment1); Error I am getting is Incovertible types;cannot cast ‘android.support.v4.app.Fragment’ to com.google.android.gms.location.PlaceAutocompleteFragment ‘. XML LAYOUT IS <android.support.v7.widget.CardView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@drawable/button_background” card_view:cardCornerRadius=”4dp” card_view:contentPadding=”0dp”> <fragment android:id=”@+id/place_autocomplete_fragment” […]

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