Tag: android-fragments

How to install last version of ADT plug-in for eclipse

I am interested in android .I use Eclipse with ADT plug-in and I have downloaded project from github site and try to understand this . But xml file don’t open the error message : “This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in”. It seem […]

Preload fragment's view in ViewPager on first run

I’m using ViewPager that holds 3 fragments, each fragment loads a list. The problem is when the application runs for the first time and I swipe to the next fragment, this fragment needs sometime to load (about 2 seconds) before its view is visible. This is a very weird behavior. All I want is once […]

Android – Make whole search bar clickable

I am using a search-view element in my fragment to implement search feature. <SearchView android:id=”@+id/search_bar” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_marginTop=”7dp” android:layout_marginLeft=”7dp” android:layout_marginRight=”7dp” android:layout_marginBottom=”7dp” android:background=”@color/white” /> The problem is only the search icon is clickable other area in the search bar is not clickable, when i click the icon only i can able to search. Can you please […]

Get Activity Context in an Adapter from a Fragment

I have a Fragment with a ListView. In the adapter I want to create a dialog. class ViewHolder { … @Override public void onClick(View v) { … AlertDialog.Builder builder = new AlertDialog.Builder(mContext); … } … } mContext is the Context from my Fragment, which I save global when the adapter is created. I get the […]

Android Volley Null Pointer Exception

I’m attempting to convert a previously Activity-based tutorial to a Fragment, but I continue to run into the NullPointerException error on my Adapter. The tutorial is based on this and I have slimmed down the constructor for the Adapter because it used to be calling an Activity. There is one possible solution here but nobody […]

Implementing DatePicker in Fragment

I’am using Fragment which is an instance of Fragment and not of DialogFragment. I did google most of the search result shows how to use DialogFragment to have DatePicker. which isn’t working in my case because of type mismatch of Fragment and DialogFragment Any example or idea would be helpful Here is the Fragment Java […]

ListFragment Support Library GetSupportFragmentManager undefined

I have a list Fragment (importing the v4 support library, build target is 2.3.3 api 11) and the following problem in my code that was working fine when the target was 3.0 and I didn’t use the library. Fragment frag1 = new ExampleFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.contentframe, frag1); ft.commit(); Now I’m getting the compile […]

Bind service to FragmentActivity or Fragment?

Is it better to bind service to FragmentActivity: bindService(Intent, ServiceConnection, int); or to Fragment: getActivity().bindService(Intent, ServiceConnection, int); What is better practice?

java.lang.IllegalStateException: Can't change tag of fragment

Hi i am getting this error while using a pageViwer and Adapter to slide across 3 fragments. here is my pageAdapter public class FreedomPageAdapter extends FragmentPagerAdapter { private List<Fragment> listFragment; public FreedomPageAdapter(FragmentManager fm, List<Fragment> listFragment) { super(fm); this.listFragment = listFragment; } /* * (non-Javadoc) * * @see android.support.v4.app.FragmentPagerAdapter#getItem(int) */ @Override public Fragment getItem(int position) { […]

Could not find class 'android.widget.ThemedSpinnerAdapter'

I have ,in a fragment, a method call who open an AlertDialog when an user tap on an button, in that dialog I would like to show a Spinner with countries ( Spain, Italy, French….) My code for the spinner is the following: RestCountries restCountries = new RestCountries(); List<RestCountries.Datum> countries = restCountries.data; String mCities =””; […]

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