Tag: android-fragments

Runtime Exception while using the Settings in Android (I am following the udacity Android Developer course)

I am new to android and following the Udacity Android developer course to learn. I am on chapter 3 where they teach about the adding the settings in your app. I have added the SettingActivity from android studio. When I click on settings menu, my app crashes. This is my pref_general.xml file <PreferenceScreen xmlns:android=”http://schemas.android.com/apk/res/android”> <!– […]

Changing pagetitle in Android Viewpager

I have a ViewPager in which I am using the getPageTitle method to get the title of the current page. Here is the Adapter code: @Override public Fragment getItem(int i) { details = productData.get(i); Fragment fragment = new ProductViewFragment(); Bundle args = new Bundle(); args.putInt(ProductViewFragment.ARG_SECTION_NUMBER, i + 1); fragment.setArguments(args); return fragment; } @Override public int […]

How to use Call Type with EventBus

I am using EventBus to notify Activity/Fragment when I get response from the server. Everything works good so far, but problem arises when I consume two network calls in same Fragment or Activity. The problem is the same method onEvent(String response) get calls for both responses from server. The response of call 1 is different […]

How to implement show and hide fragment inside fragment in android

How to implement show and hide fragment inside fragment in Android? I have added two fragment inside activity. One fragment containing menu and one fragment contain sub menu. I have lot of button in menu fragment like home, idea, etc. If i click idea button. I have to show sub menu. If I again click […]

Android: what replaced android.support.v4.app.NavUtils in later APIs?

I’m programming an app for tablets, API level 13 or higher. Therefore I do not need the support library, i.e. android.support.v4.app.Fragment has been replaced by android.app.Fragment and similar. In the support library there was a neat class android.support.v4.app.NavUtils, but I cannot find any equivalent class in the higher APIs. So what replaced it or its […]

Crash after adding item to action bar's options menu from Fragment followed by orientation change

I’m using ActionBarSherlock and ViewPagerIndicator to display Fragments as tabs. One of those Fragments adds items to ActionBar: private String[] mapNames; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); // init an String array `mapNames` which is used when populating submenu // … } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_maps, menu); SubMenu […]

DialogFragment displayed from onContextItemSelected doesn't survive onPause/onResume

I have a DialogDragment which I can show one of two ways: 1) By tapping on a ListView item from its OnItemClickListener 2) By activating a the ListView’s context menu and selecting a menu item Doing #1 works fine under all lifecycle events, but if I invoke it via #2 and I pause the activity […]

Implement feature like iOS app closing vertical Swipe-to-Dismiss with ViewPager

I currently have Views lined up horizontally in a ViewPager and can cycle through them with a PagerAdapter. Currently, to perform the action that I would like to do on swipe, I have to do a double-tap on the View’s page. I could post code, but it’s somewhat difficult to extract the necessary pieces… What […]

Different toolbar for fragments and Navigation Drawer

Please, explain to me… I have Navigation Drawer in my Activity and it syncs with Toolbar (like ActionBar). Activity has few fragments and in different fragments I need to use different AppBar modes (parallax in one, simple in another). So, I think that I should set CoordinatorLayout in each frament with AppBar and content. But […]

Android memory management granularity – Activity or Process?

I am seeing inconsistent documentation and discussion regarding what happens when Android is low on memory and the steps the OS takes to re-claim memory. More specifically, does Android kill at the granularity of activity/fragment, or entire process? For example, if Activity B is launched in front of Activity A (and both activities are part […]

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