How to detect which dynamically created button inside a Fragment was clicked, from Activity?

I have a Fragment class that dynamically creates a grid of Buttons. An instance of that fragment is then created within the main activity which displays the grid. Here is my code: Grid.java public class Grid extends Fragment { LinearLayout myLayout; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); myLayout = new … Continue reading “How to detect which dynamically created button inside a Fragment was clicked, from Activity?”

Fragment showing blank but has loaded layout

I am practicing with android fragments and have started with navigation drawer activity in android. i have already created three layouts and java files for those fragments. the problem is there is no content. it just shows a blank page. i have been following a tutorial from this site. I have already created a frame … Continue reading “Fragment showing blank but has loaded layout”

Android fragments strangely disappears when tag is set

I’ve two types of Fragment in PageView. The first one is TextFragment containing TextView and having set tag on it. The other ones are ImageFragments containing ImageView and having no tag. Images are loaded asynchronously from asset folder. The problem is that the second (and sometimes also some other) fragment does not show the content … Continue reading “Android fragments strangely disappears when tag is set”

Multiple Line Graphs in Fragment causes application Crash. Android Studio using Example Code

I’m using an example from MPAndroidChart (The Activity I am using as a template is called: ListViewMultiChartActivity ) I’m making a part of an application where I use fragments to show two views with graphs. My problem is with one of the fragments where I would like a list view with multiple graphs. I have … Continue reading “Multiple Line Graphs in Fragment causes application Crash. Android Studio using Example Code”

Displaying Default Text if Value is empty or null in Android

I have an app that has profile activities for me (MyProfileAboutFragment), and for my friends (AboutFragment). I get my friends list from server, and when I click on it I send username, photo, about, phone etc via intent to my AboutFragment. If there is a field missing it displays the default text. This works correctly. … Continue reading “Displaying Default Text if Value is empty or null in Android”

Not able to update middle fragment in View Pager.

I’ve been working on a TAB layout with 3 tabs. My problem is I’m unable to update,refresh 2nd tab swiping between the pages. As per my debugging I swipe from tab one to second, the third is being called at getItem(int position), similarly fragment one is being called swiping from third tab to second. The … Continue reading “Not able to update middle fragment in View Pager.”

How can I change ViewPager fragment from another fragment? Without doing new

This application is a questionnaire. I used ViewPager to host the fragments. When the user gets to the last screen, EndingQuestionsFragment, they have a button which then press on and it takes them to the main screen (not important for my problem). If there is a question which is not answered, when the button is … Continue reading “How can I change ViewPager fragment from another fragment? Without doing new”

Fragment doesn't update values from other fragment

I am quite new in android, my intention is to pass this values to a fragment that it is my current fragment. But I want to update the fragment, I have this data in a different fragment. When I execute this my bundle goes to the fragment. It doesn’t change even I can do setText … Continue reading “Fragment doesn't update values from other fragment”