在选项卡上更改onResume未在android中调用

时间:2016-06-15 05:30:03

标签: android

我有两个标签,分别是交易片段中的交易和故事片段onResume方法,当我将片段更改为故事时获取一些数据,然后再次回到未经调用的交易简历上的交易,以及当我切换到故事标签并转到另一个时活动并返回故事标签中的标签活动onResume of deal标签名为.pls help。

代码:-Tab

TabLayout m_TabLayout = (TabLayout) findViewById(R.id.tab_layout);// finding Id of tablayout
    m_TabLayout.addTab(m_TabLayout.newTab().setText("Deals"));// add deal listin tab
    m_TabLayout.addTab(m_TabLayout.newTab().setText("Stories"));// add stories tab
    m_TabLayout.setTabGravity(TabLayout.GRAVITY_FILL);// setting Gravity of Tab

    m_ViewPager = (ViewPager)findViewById(R.id.pager);//finding Id of ViewPager
    CDealMainListingPager m_oDealMainScreenPager = new CDealMainListingPager
            (getSupportFragmentManager(), m_TabLayout.getTabCount());
    m_ViewPager.setAdapter(m_oDealMainScreenPager);// adiing adapter to ViewPager
    m_ViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(m_TabLayout));// performing action of page changing
    m_TabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            m_ViewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });

和交易的代码onResume

private void getDetails() {// get details of user from shared preference...
    CLoginSessionManagement m_oSessionManagement = new CLoginSessionManagement(getActivity());// crating object of Login Session
    HashMap<String, String> user = m_oSessionManagement.getLoginDetails();// get String from Login Session
    m_szMobileNumber = user.get(CLoginSessionManagement.s_szKEY_MOBILE).trim();// getting password from saved preferences..........
    m_szEncryptedPassword = user.get(CLoginSessionManagement.s_szKEY_PASSWORD).trim();// getting mobile num from shared preferences...

    sz_RecordCount = String.valueOf(m_n_DefaultRecordCount);// increment of record count
    m_n_DeafalutLastCount = 0;
    sz_LastCount = String.valueOf(m_n_DeafalutLastCount);// increment of last count...

    s_oDataset = new ArrayList<>();// making object of Arraylist


    if (NetworkUtil.isConnected(getActivity())) {
        postDealListingDatatoServer();// here sending request in onCreate
    } else {

        Toast.makeText(getActivity(), "Please check internet connection !", Toast.LENGTH_LONG).show();
    }


}

@Override
public void onResume() {
    super.onResume();
    getDetails();

}

0 个答案:

没有答案