【问题标题】:Viewbadger Count not getting updated dynamicallyViewbadger Count 未动态更新
【发布时间】:2015-09-10 06:40:32
【问题描述】:

当数据库使用任何操作更新时,viewbadger 计数器不会在 DashboardActivity 上更新。

public static BadgeView badge1;
public static BadgeView badge2;


@Override
public void onResume() {
    super.onResume();

      Badgeupdate(); // function to update badge           
}


public void Badgeupdate() {   

    neworders_count=0;     
    pendingorders_count=0;        


    badge1 = new BadgeView(this, v1); // v11 is View
    fetch_neworders_count();  // fetch data count query
    CurrentActivity.badge1.setText(neworders_count + "");
    badge1.show();

    badge2 = new BadgeView(this, v2); // v2 is View
    fetch_pendingorders_count();  // fetch data count query
    CurrentActivity.badge2.setText(pendingorders_count + "");
    badge2.show();  



}

我有用户 Viewbadger 库 - https://github.com/jgilfelt/android-viewbadger

【问题讨论】:

    标签: android badge activity-lifecycle


    【解决方案1】:

    请尝试以下代码:

    public static BadgeView badge1;
      badge1 = new BadgeView(MainActivity.this, v1); //v1 is view selected to set badge
    
                badge1.setText("0");
                badge1.show();
    
    MainActivity.badge1.setText("hello badge"); //call it from anywhere to update
    

    在您的徽章更新中仅使用 badge.setText("hello");没有更多的东西,你在这里一次又一次地创造它们。

    【讨论】:

    • 没有。一旦我单击它(打开另一个活动并执行数据更改)并返回此。它没有得到更新
    • @Androider 嘿,你知道如何动态改变 viewbadger 的值了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    相关资源
    最近更新 更多