fragment

Use EditText in a DialogFragment to change TextView in Main Activity?

天涯浪子 提交于 2019-12-25 16:55:44
问题 So I'm working on my first real attempt at an Android app, just a simple scorekeeper for softball games. I've got it tallying scores, outs, etc, and right now it just displays "Home" and "Away." I'd like to give users the chance to enter in actual team names. To this effect, I added a custom AlertDialog that pops up with an EditText, so when you hit "OK" it'll update the Home/Away team name. The problem is I've been Googling this for most of the week and I've not found a single way to

Use EditText in a DialogFragment to change TextView in Main Activity?

时光怂恿深爱的人放手 提交于 2019-12-25 16:55:30
问题 So I'm working on my first real attempt at an Android app, just a simple scorekeeper for softball games. I've got it tallying scores, outs, etc, and right now it just displays "Home" and "Away." I'd like to give users the chance to enter in actual team names. To this effect, I added a custom AlertDialog that pops up with an EditText, so when you hit "OK" it'll update the Home/Away team name. The problem is I've been Googling this for most of the week and I've not found a single way to

How to reference a fragment's methods from an activity?

南楼画角 提交于 2019-12-25 14:07:32
问题 I have a viewpager app that I am working on with 3 fragments. I am adding the fragments dynamically via the FragmentStatePagerAdapter like that: public class ViewPagerAdapter extends FragmentStatePagerAdapter { CharSequence Titles[]; // This will Store the Titles of the Tabs which are Going to be passed when ViewPagerAdapter is created int NumbOfTabs; // Store the number of tabs, this will also be passed when the ViewPagerAdapter is created // Build a Constructor and assign the passed Values

Removing continuous Firebase listeners on Fragment change

与世无争的帅哥 提交于 2019-12-25 11:55:16
问题 Each Fragment in my application has their own set of continuous Firebase listeners. These become unnecessary once the active Fragment has changed, however, the listeners continue in the background. Besides that, these old listeners may trigger View updates for the previous Fragment, which may then crash the application. So, I'd like to be tidy and clean up the listeners once the Fragment changes. I do not know how, but I have an alternative solution and I was curious about your thoughts and

Textview in android fragment duplicated in landscape layout

北慕城南 提交于 2019-12-25 09:08:32
问题 I am trying to make an app with two fragments, one containing a list of groups (called OverviewFragment) and one fragment containing the details of selected group (called DetailsFragment). I want only one fragment to be visible at a time in portrait mode and both to be visible simultaneously in landscape mode. I have two problems. First of all the transition between portrait and landscape is very unstable and leads to a variety of crashes, i.e: a blank screen, "No view found", "Error

updating Fragments in a ViewPager

左心房为你撑大大i 提交于 2019-12-25 08:34:23
问题 i am having problems trying to update/replace Fragments in a ViewPager. the problem is that the old fragments simply won't get replaced by the new ones. i have read a couple of solutions on stackoverflow, and tried them, but it still doesn't work. anyone have any ideas why? i will explain what i am trying to do below. i have a Pojo class public class Pojo { public String text; public Pojo(String text) { this.text = text; } } i have a group class, PojoGroup public class PojoGroup { public

Android: Implement inner class in outer class; callback from inner class and outer class

早过忘川 提交于 2019-12-25 05:29:09
问题 I have multiple fragments in one activity that should be able to pass data inbetween them. I have used tutorials to implement callbacks. My MainActivity is the outer class in which my fragment classes are. Furthermore I have a FragmentPagerAdapter that handles the fragment transitions. Well the thing is, Eclipse wont let me implement my callback interface, that is included in one of the Fragments, for my MainActivity outer class. This is the structure of my code: public class MainActivity

Android strange error

心已入冬 提交于 2019-12-25 05:05:41
问题 I have made an listview application, then i created a new one with fragments and want to implement listview to fragments. But when i do i got an strange error. public class Fragment1 extends Fragment { private ArrayList<FeedItem> feedList = null; private ProgressBar progressbar = null; private ListView feedListView = null; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.list_row_layout,

getFragmentManager( ) and support package

我只是一个虾纸丫 提交于 2019-12-25 04:56:21
问题 I'm learning to use fragments for build a dynamic application, but I've a problem with the Fragment Manager. When I pass it by the method getFragmentManager( ) is shown a warning because it returns the Fragment Manager of android.app, not from the support library. Do you know how to fix it? 回答1: You should use getSupportFragmentManager() instead of getFragmentManager() Also, make sure you are extending FragmentActivity and not just Activity . 来源: https://stackoverflow.com/questions/15460028

Error on my fragment “android.app.Application cannot be cast to”

人走茶凉 提交于 2019-12-25 04:38:22
问题 Just following this question: Using Google Analytics To Track Fragments I have an app which implements a Navigation Drawer , so they're Fragments but Google Analytics don't work on this line: final Tracker tracker = ((App) getActivity().getApplication()).getTracker(); The Fragment : public class Accueil extends android.support.v4.app.Fragment { @Override public void onResume() { super.onResume(); final Tracker tracker = ((App) getActivity().getApplication()).getTracker(); if(tracker != null){