您的位置:首页 > 移动开发 > Android开发

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

2015-11-25 17:38 633 查看
这里是使用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;
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: