Android学习心得③ - Layout模拟ListView item按下效果

来源:互联网 发布:有创意的淘宝店铺设计 编辑:程序博客网 时间:2024/05/29 15:49

这里是使用setOnTouchListener模拟Listview类似效果

final FrameLayout aboutLayout = (FrameLayout) findViewById(R.id.about_layout);        aboutLayout.setOnTouchListener(new View.OnTouchListener() {            @Override            public boolean onTouch(View v, MotionEvent event) {                if (event.getAction() == MotionEvent.ACTION_DOWN) {                    aboutLayout.setBackgroundColor(getResources().getColor(R.color.backgroundDark));                } else if (event.getAction() == MotionEvent.ACTION_UP) {                    aboutLayout.setBackgroundColor(getResources().getColor(R.color.backgroundLight));                    Intent i = new Intent(SettingsActivity.this, AboutActivity.class);                    startActivity(i);                }                return true;            }        });
0 0
原创粉丝点击