fragment

Adding a Fragment with add() method doesn't hide previous fragments

流过昼夜 提交于 2020-01-01 09:46:55
问题 I'm experiencing "unexpected behaviour" when using add() method to add a new fragment. I want to add a new fragment on a FrameLayout, but when I do it the previous fragment stills visible. Is this the expected result when using add() method? It is because I am using a FrameLayout and add() method just place a fragment over the FrameLayout without affect the previous one? Thx 回答1: Not a bug. Try replace(..). instead adding to the back stack if required. EDIT I think that using replace or

Spring Boot: Thymeleaf not resolving fragments after packaging

不问归期 提交于 2020-01-01 07:04:28
问题 im using fragments like this: @RequestMapping(value="/fragment/nodeListWithStatus", method= RequestMethod.GET) public String nodeListWithStatus(Model model) { // status der nodes model.addAttribute("nodeList", nodeService.getNodeListWithOnlineStatus()); return "/fragments :: nodeList"; } The templates are in /src/main/resources/templates. This works fine when starting the application from IntelliJ. As soon as i create an .jar and start it, above code no longer works. Error: [2014-10-21 20:37

How to check if Fragment was restored from a backstack?

北慕城南 提交于 2020-01-01 05:28:09
问题 Is that possible to check if Fragment was restored from a backstack? For example, if I had one, then replaced by another and back to previous by tapping "back" android button? 回答1: You need to have your own backstack and keep track of it. Look at this: http://adblogcat.com/fragment-transition-animations-while-hiding-the-previous-fragment/ The code holds its own stack of fragments and hides them instead of removing them, giving it the same effect as replace (with backstack) except it doesn't

Refreshing ArrayAdapter onResume [notifyDataSetChanged() not working]

微笑、不失礼 提交于 2020-01-01 04:49:11
问题 I am creating a contact list app using Fragments where one frag is a list of names in the contact list and the other is the rest of the details. Here is the class that displays the list of names public class MyListFragment extends ListFragment { private ContactStorage contactStorage = new ContactStorage(); public final static String TAG = "FRAGMENTS"; private MainActivity parent; ArrayAdapter<String> adapter; ArrayList<String> entries = new ArrayList<String>(); String array[]; public View

How to prevent calling onCreateView when back button pressed in fragment in android

假装没事ソ 提交于 2020-01-01 04:12:07
问题 In my application, I have tabbar functionality. In one tab i am displaying server data in lisview, and on clicking on that detail page for that list item will be open in new fragment. But when I press back button from that detail page, every time oncreateview called of previous page, so every time listview created and new fetches new server data. So how to prevent such and just display previous state when back button press? 回答1: I know it has been too long to give this answer but what i am

Why would I ever want `setRetainInstance(false)`? - Or - The correct way to handle device rotation

瘦欲@ 提交于 2020-01-01 04:08:13
问题 Please correct me if I'm wrong on any of this. This is a kind of clarifying question since I haven't seen it explicitly written anywhere. In Android 4, you can call setRetainInstance(true) on a Fragment so that on configuration changes (which basically means device rotation), the Fragment java object isn't destroyed and a new instance of it isn't created. That is, the instance is retained. This is much more sane and less infuriating than in Android 1-3 since you don't have to deal with

android - do you ever have to add fragments to the manifest

大憨熊 提交于 2020-01-01 01:16:09
问题 Im using a fragment that is supposed to display a webview. When I try to instantiate it from the class that uses it I get the following warning in my logcat. 02-21 23:26:46.843: W/System.err(32468): android.content.ActivityNotFoundException: Unable to find explicit activity class {get.scanner/get.scanner.WebFrag}; have you declared this activity in your AndroidManifest.xml? Im just learning how to use fragments and Ive never tried declaring them in my manifest and I havent seen anywhere

How to cache a fragment view

梦想的初衷 提交于 2020-01-01 01:13:09
问题 I'd like to cache a fragment view. My Activity has swipeable tabs and each tab calls a different fragment. But when i swipe between tabs the transition seems a quite slow because of the destruction of the fragment view, that is rebuilded during the swipe operation. Does anyone know how can i cache the view of each fragment to prevent this issue? I work with library support v4 and api 14 I tried to implement a constructor for the fragments, called by the activity container of the fragments: i

Intent from Fragment to Activity

烂漫一生 提交于 2019-12-31 12:11:33
问题 I was trying to go to another page using button , but it always fail. Here is my First Class with its XML: public class FindPeopleFragment extends Fragment { public FindPeopleFragment(){} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_home, container, false); return rootView; } public void goToAttract(View v) { Intent intent = new Intent(getActivity().getApplication(),

Best way to combine fragment and object caching for memcached and Rails

纵饮孤独 提交于 2019-12-31 08:39:32
问题 Lets say you have a fragment of the page which displays the most recent posts, and you expire it in 30 minutes. I'm using Rails here. <% cache("recent_posts", :expires_in => 30.minutes) do %> ... <% end %> Obviously you don't need to do the database lookup to get the most recent posts if the fragment exists, so you should be able to avoid that overhead too. What I'm doing now is something like this in the controller which seems to work: unless Rails.cache.exist? "views/recent_posts" @posts =