fragment

fManager.getFragmentById() returns null

♀尐吖头ヾ 提交于 2020-01-05 09:34:36
问题 I asked a question like this one the other day... this. I marked it as resolved, because the mistake was that isPlayServicesAvailable() returned false, because I had not the up to date Google Play Services. I have them now...but still NPE. The code: GoogleMap map; FragmentManager fmanager = getSupportFragmentManager(); Fragment fragment = fmanager.findFragmentById(R.id.map);//after this, fragment is null SupportMapFragment supportmapfragment = (SupportMapFragment)fragment; map

Gather all Strings from SharedPreference getAll() Method?

北慕城南 提交于 2020-01-05 08:27:18
问题 I'm trying to figure out how to set every String and Key name from my app's SharedPreferences using the getAll() method so I can use those values to name populated buttons and assign those buttons to the access the proper string in sharedpreferences to display in a textview. The problem is I do not know how to save these values to a String or String Array because I haven't ever dealt with maps before. If anybody could help me store my SharedPreferences keys and string values to a String array

Fragment shows twice on top of eachother

流过昼夜 提交于 2020-01-05 08:12:26
问题 I im displaying fragments in my activity, but seems that some fragments are displaying(instatiating) twice. I'm double checking my code but and in my opinion all should be ok. The issue is when I show the fragment its ok, but after showing another fragment and showing the same fragment it's like reloading the calling the same fragment all over again and it shows updated data - although no data updating was done. this is how I call my fragments: public void showFragment(Fragment fragment,

ListFragment onCreate called twice

大城市里の小女人 提交于 2020-01-05 08:04:39
问题 how can I avoid that the onCreate method in the ListFragment ist called twice? I have search functions for my list. The search results might be shorter than the list, which I display after creating the ListFragment (at the moment you can see the long list in the background and the shorter list with the search result in the foreground). Here my code snippets: in my FragmentActivity: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Viewpager loose fragment connection on low memory kill

岁酱吖の 提交于 2020-01-05 04:17:13
问题 in my activity i use viewpager. I create two fragments and attach the to the view pager and time to time calling some methods from this fragments in my activity.. afer the app is killed on low memory and recreated fragments are there but no connection with the viewpager somehome.. i can not call MyFragment.mymethod().. it says MyFragment is null public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Override public

Replace Fragment with another on back button

瘦欲@ 提交于 2020-01-05 03:09:07
问题 I'm trying to override the Back Button because it's closing my app when I push on, I have different Fragments: Fragment A: Index (When I press back button, it's will close the app) Fragment B (When I press back button it will go back to the Fragment A) Fragment C (When I press back button it will go back to the Fragment A) And I have my Main Activity: It manage my Fragments (for have a Navigation Drawer). I found many posts on this but I can't implement them: On Fragment B for exemple:

Caused by java.lang.IllegalStateException: Can't create ViewModelProvider for detached fragment

泄露秘密 提交于 2020-01-04 03:49:10
问题 I need some help to ressolve the following crash. I am refreshing my list on Restart in Activity by calling fragment in viewpager to refresh its list. Following is the stacktrace of the crash: Caused by java.lang.IllegalStateException: Can't create ViewModelProvider for detached fragment at android.arch.lifecycle.ViewModelProviders.checkActivity(ViewModelProviders.java:51) at android.arch.lifecycle.ViewModelProviders.of(ViewModelProviders.java:105) at com.ui.fragments.mainpagerfragments

How to implement button SetOnClickListener in a fragment?

最后都变了- 提交于 2020-01-04 03:24:09
问题 I'm working on a small project and I want to use a Slider Menu. Long story short I happen to find a source code of a slider menu using drawer from some website and it works very well on my device. However I'm a little bit confused migrating my previous activity into this slider menu because they use fragment for each individual item on the listView. To simple things up I want to migrate an activity that capable of do a Ping function. it's xml file consist of one EditText, a Button, and a

关于重绘和回流

£可爱£侵袭症+ 提交于 2020-01-04 02:39:03
1. 浏览器渲染机制 浏览器采用流式布局模型( Flow Based Layout ) 浏览器会把 HTML 解析成 DOM ,把 CSS 解析成 CSSOM , DOM 和 CSSOM 合并就产生了渲染树( Render Tree )。 有了 RenderTree ,我们就知道了所有节点的样式,然后计算他们在页面上的大小和位置,最后把节点绘制到页面上。 由于浏览器使用流式布局,对 Render Tree 的计算通常只需要遍历一次就可以完成,但 table 及其内部元素除外,他们可能需要多次计算,通常要花3倍于同等元素的时间,这也是为什么要避免使用 table 布局的原因之一。 2. 重绘 由于节点的几何属性发生改变或者由于样式发生改变而不会影响布局的,称为重绘,例如 outline , visibility , color 、 background-color 等,重绘的代价是高昂的,因为浏览器必须验证DOM树上其他节点元素的可见性。 3. 回流 回流是布局或者几何属性需要改变就称为回流。回流是影响浏览器性能的关键因素,因为其变化涉及到部分页面(或是整个页面)的布局更新。一个元素的回流可能会导致了其所有子元素以及DOM中紧随其后的节点、祖先节点元素的随后的回流。 <body> <div class="error"> <h4>我的组件</h4> <p><strong>错误:<

How to pass from one fragment to another

喜夏-厌秋 提交于 2020-01-03 20:58:22
问题 In my app I have navigation drawer with some fragments. When I choose in the drawer I do this code: FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container, f, tag); ft.commit(); in the MainActivity. Now in one fragment I want to put a TabLayout in the bottom of the screen and I have this troubles: is it possible to replace from one fragment to another? Where could I put fragmentTransaction ? if I want to call a third fragment (for example a Send button in one of this tab