在Nougat更新后,用户界面无法正常工作

时间:2017-02-13 09:41:22

标签: android android-7.0-nougat android-7.1-nougat

在android 7+(nougat)运行手机上我的ui没有响应,直到我在调试模式下运行我的代码但是对于运行android版本的设备工作正常< 7

以下是OnCreate的活动代码:

    super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            threadForFirebaseReport();
            //Action Bar content
            toolbar = (Toolbar) findViewById(R.id.toolbar_main);
            //spinner.setVisibility(View.VISIBLE);
            frameLayoutMain = (FrameLayout) findViewById(R.id.main_fragment);

            //Fragments
            fragmentManager = this.getFragmentManager();
            homeFragment = new HomeFragment();

            progressDialog = new ProgressDialog(this);
            mapCity = new HashMap<Long, String>();
            cityItems = new ArrayList<String>();



            //backToolbarButton = (ImageView) toolbar.findViewById(R.id.toolbarback_button);
            /*actionBar = getSupportActionBar();*/
            sharedPreferences = this.getSharedPreferences(Constants.SHAREDPREFERENCE_FILENAME, Context.MODE_PRIVATE);
            setSupportActionBar(toolbar);

            //hiding default app icon
            actionBar = getSupportActionBar();
            actionBar.setDisplayShowHomeEnabled(false);
            //displaying custom ActionBar
            View mActionBarView = getLayoutInflater().inflate(R.layout.action_bar, null);
            actionbarImage = (ImageButton) mActionBarView.findViewById(R.id.toolbarback_button);
            actionbarText = (TextView) mActionBarView.findViewById(R.id.toolbar_text);
            actionBar.setCustomView(mActionBarView);
            actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
            getSupportActionBar().setElevation(0);
            actionbarImage.setOnClickListener(this);
            spinner = (Spinner) findViewById(R.id.spinner);

            threadForAppsFlyer();



            //For Navigation Drawer
            drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
            listViewDrawerLayout = (ListView) findViewById(R.id.drawer_list);
            navigationDrawerAdapter = new NavigationDrawerAdapter(getApplicationContext());
            listViewDrawerLayout.setAdapter(navigationDrawerAdapter);
            drawerLayout.setScrimColor(Color.TRANSPARENT);
            try {
                drawerLayout.setScrimColor(getResources().getColor(R.color.colorBlackAlpha));
            } catch (Exception e) {

            }
            listViewDrawerLayout.setOnItemClickListener(HomeActivity.this);


            //For navigation DrawerActionbar button
            actionBarDrawerListener = new ActionBarDrawerToggle(
                    this,
                    drawerLayout,
                    toolbar,
                    R.string.drawer_open,
                    R.string.drawer_close) {

                @Override
                public void onDrawerClosed(View drawerView) {

                }

                @Override
                public void onDrawerOpened(View drawerView) {
                    super.onDrawerOpened(drawerView);
                    editor = sharedPreferences.edit();
                    editor.putString("fragment", "0");
                    editor.commit();

                }
            };
            drawerLayout.addDrawerListener(actionBarDrawerListener);
changeHomeFragment();

每当我使用debugpoint在debug中运行代码并继续使用它时就开始工作了虽然这个问题在Android版本到了marshmallow。

0 个答案:

没有答案