Tag: android-fragments

How to pass data from activity to fragment

I have some problems passing data from an activity to fragments in it. I searched around but didn’t find an answer which suit my situation well. I have 2 fragment class named CurrentFragment.java and HistoryFragment.java. I initialize them as tabs in an Activity. Tab tab = actionBar.newTab() .setText(R.string.tab_current) .setTabListener(new TaskitTabListener<CurrentFragment>( this, “current”, CurrentFragment.class)); actionBar.addTab(tab); tab […]

Updating a fragment in response to Android Navigation Drawer interaction

The Android app I’m working on has a single MainActivity and each screen of the app is implemented as a Fragment. Each fragment is instantiated like this in the MainActivity as a private class variable: public class MainActivity extends Activity implements MainStateListener { private FragmentManager fm = getFragmentManager(); private BrowseFragment browseFragment = BrowseFragment.newInstance(); … There […]

Is it possible to disable access to fragment's layout(views) from parent activity?

I’m working on a library which will provide fragment with some input fields in it. These input fields will contain user’s private information that app which uses my library should not have access to. Therefore edittexts or we can say fragment’s layout cannot be accessed from activity(findViewById,getChildAt..) where this fragment is attached to. Usage of […]

Navigation Drawer is slow with complex view

In my app i’m using Navigation Drawer and it works very fine. But if the Fragment to show contains much TextView, ImageView and Layout, when i click the item, the view is glitching. I would improve this lag. The effect is the same by my Galaxy Nexus and with Nexus 4 so i think the […]

Shared element transition don't have the expected behaviour

I implemented the shared element transition between from an image in a RecyclerView to an image in a new Fragment. The RecyclerView is hosted in a fragment hosted by an Activity and the target fragment is hosted inside another Activity. When I click on my image, the transition is happening like expected and I get […]

Tablet UI doesn't work on my app

I am trying to create an app which has two different UIs for tablets and phones, and I’m using fragments to implement this. I have created two separate xml files for each tablet and phone layout and both are called activity_main.xml, with the phone layout being placed in the res/layout folder and the tablet layout […]

Flip animation in Android for a Fragment transaction setting a “z” index or a camera

I’m trying to animate transaction between two fragments, with this code: http://developer.android.com/training/animation/cardflip.html But the result is exactly this: http://developer.android.com/training/animation/anim_card_flip.mp4 However, I want this result: https://www.youtube.com/watch?v=52mXHqX9f3Y The difference, is that even tho both rotate 180ยบ, the second one does it with a different camera (Z-Axis). So the question is: Can I apply a Z-Index to object […]

NavigationDrawer activity is cluttered with fragment callbacks and application business logic

An Activity containing NavigationDrawer is supposed to juggle its fragments. My problem is that the drawer has to be available on all possible screens of the application, which makes my only activity MainActivity very cluttered with fragment-callback code and different sorts of navigation/business logic. As the application grows it becomes harder to navigate through the […]

MapFragment causing NullPointerException at getMapAsync(this) method

I have implemented an activity which adds MapFragment at run time. The MapFragment xml has static fragment and I’m trying to get add at run time. Also I found there are some issues in Lollipop adding the map fragment at runtime. Kindly check Issue raised and temporary solution I have also given my codes below, […]

Android: using fragments programmatically

For some reasons I can’t use xml layout files. But I need to create a tablet android app. I decided to use fragments. I want to create the same layout that this xml generates: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”horizontal” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <fragment class=”com.example.ItemsList” android:id=”@+id/items_list” android:layout_weight=”1″ android:layout_width=”0dp” android:layout_height=”fill_parent” /> <FrameLayout android:id=”@+id/item_details” android:layout_weight=”1″ android:layout_width=”0dp” android:layout_height=”fill_parent” android:background=”?android:attr/detailsElementBackground” […]

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