我正在尝试根据颜色在点击时运行不同的方法。我可以通过视图保持来获取颜色值,但是无论我将视图保持器设置为哪种颜色,我总会得到0。
我已导入颜色的包装
import static android.graphics.Color.GREEN;
import static android.graphics.Color.WHITE;
import android.graphics.Color;
OnClick代码
public void onClick(View v) {
Log.d("recycler","Current color is " +viewHolder.viewLayout.getSolidColor() );
if(viewHolder.viewLayout.getSolidColor() == GREEN)
{
// remove from battleRSList
viewHolder.viewLayout.setBackgroundColor(WHITE);
}
else if(viewHolder.viewLayout.getSolidColor() == 0)
{
newDay.thePatDown(viewHolder.eventName.getText().toString(),day,context);
viewHolder.viewLayout.setBackgroundColor(GREEN);
Log.d("recycler","its white");
}
}
});