将当前类别设置为活动

时间:2016-09-22 07:23:34

标签: timber

在类别页面上,我希望添加一个"活跃的"将当前页面相关链接分类以显示菜单中选择的类别。

目前,我列出了所有帖子类别,并通过

链接到相关网页
class MyAnimatorUpdateListener implements ValueAnimator.AnimatorUpdateListener
{
    private View view;
    private PathMeasure pathMeasure;
    private float[] coordinates = new float[2];

    public MyAnimatorUpdateListener(View view, PathMeasure pathMeasure)
    {
        this.view = view;
        this.pathMeasure = pathMeasure;
    }

    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
        float distance = (float) animation.getAnimatedValue();
        pathMeasure.getPosTan(distance, coordinates, null);
        view.setTranslationX(coordinates[0]);
        view.setTranslationY(coordinates[1]);
    }
}

我尝试使用if语句,但似乎无法正确使用。

1 个答案:

答案 0 :(得分:0)

通过将当前类别设置为活动来管理解决此问题:

{% for cat in categories %}

     <li><a style="margin: 0;" href="{{ cat.link }}" class="menu-item {% if category|capitalize == cat.name %}active{% endif %}">{{cat.name}}</a></li>

{% endfor %}
相关问题