【发布时间】:2014-10-03 13:19:10
【问题描述】:
我的应用程序中有一个非常复杂的 listView,它可以根据每个 rowView 的一些标志启动不同的活动(某些 rowView 甚至无法被点击)。
我选择在每个 rowView 上添加一个 OnClickListener 来启动活动,但是在我将侦听器添加到 rowView 后,当我单击它时它不再动画(它应该变得更暗,就像默认的 android 实现一样) . 没有侦听器的 RowViews 仍然有动画,所以我想我错过了一些让它变暗的调用。
有什么提示吗?
编辑:由于我被要求一些代码,这里是我的 customAdapter 的 getView 的简化快照
public View getView(final int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.customlistitem, null, true);
if (infoList.get(position).isSeparator()){
// Populate the view and don't add a listener
} else {
// Populate the view in some other way and add a listener
rowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, myActivity.class);
intent.putExtra("an_extra", new Object());
intent.putExtra("another_extra", new Object());
intent.putExtra("a_third_extra", new Object());
context.startActivity(intent);
}
});
}
return rowView;
}
如果对象有标志isSeparator,当我点击它时它会变暗,否则它不会。
【问题讨论】:
-
请贴一些代码
标签: android android-listview android-animation