在android中活动开始时屏幕闪烁

时间:2016-04-14 11:01:53

标签: android

我已将片段重定向到activity.Progress轮在获取数据之前旋转,然后在从Web服务获取数据后停止。从Web服务加载数据后,屏幕闪烁几秒钟。闪烁所有数据后在activity中显示。如何删除android中的闪烁效果? `

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_post);

        FontChangeCrawler fontChanger = new FontChangeCrawler(getAssets(), "arial.ttf");
        fontChanger.replaceFonts((ViewGroup) this.findViewById(android.R.id.content));

        SharedPreferences prefs1 = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
        userID= prefs1.getString("userid", null);
        System.out.println("userid" + userID);

        Intent i = getIntent();
        useridpost = i.getStringExtra("postuserid");
        subuser=i.getStringExtra("subuserid");

        btnBack=(ImageButton)findViewById(R.id.button_back);
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(checking){
                    Intent cancel = new Intent(PostActivity.this, MainActivity.class);
                    cancel.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    cancel.putExtra("testedit", "testedit");
                    startActivity(cancel);
                }
                else{
                    finish();
                }
            }
        });
        emptyView=(TextView)findViewById(R.id.empty_view);

        if(subuser!=null){
            if(subuser.equals(userID)){
                emptyView.setText("No Posts for you");
            }
            else{
                emptyView.setText("No Posts to show");
            }
        }

        if(useridpost==null) {
            // editor.putString("useridfromprofile", userID);
            userID = prefs1.getString("userid", null);
            System.out.println("user id from shared preferences"+userID);
        }
        else
        {
            userID=useridpost;
            System.out.println("user id from arguments"+userID);
        }

        pw=(ProgressWheel) findViewById(R.id.pw_spinner);
        obj.styleRandom(pw,getApplicationContext());

        recyclerView=(ListView)findViewById(R.id.recycler_view);

//        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter=new CustomPostAdapter1(this,feedsList,PostActivity.this);
        recyclerView.setAdapter(adapter);
        getProfilePosts();

    }

1 个答案:

答案 0 :(得分:0)

试试这个

在退出activity时,请致电getWindow().setExitTransition(null); 在输入activity时,请致电getWindow().setEnterTransition(null);

它可以防止退出activity的淡出和进入activity的淡入淡出,从而消除明显的眨眼效果。