문제

I need help with following... I have listview with actionbar(with textview) and listview is populated with custom cursor adapter.

I want to update textview on my actionbar on specific activity in custom cursor adapter class. (when user types a number in different listrows I want the sum of those rows displayed on my actionbar) Now, i have covered that operation, i just need to display that number on textview which is on actionbar. How can I do that?

My custom cursor extends CursorAdapter, not actionbaractivity. Can I somehow get actionbar textview in cursor adapter and set it there?

도움이 되었습니까?

해결책

CursorAdapter requires that you pass in a Context when you initialize it. If you want to update the ActionBar within your CursorAdapter, you could initialize an ActionBar object by casting Activity to the constructor's Context.

private final ActionBar mActionBar;

public YourAdapter (Context context, Cursor c, int flags) {
    mActionBar = ((Activity) context).getActionBar();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top