Custom background for activatedBackgroundIndicator on ActionBarSherlock doesn't work

前端 未结 1 1088
醉话见心
醉话见心 2021-01-02 02:49

I\'m using ActionBarSherlock and I\'m trying to customize the activatedBackgroundIndicator attribute for the row background.

If I use the l

相关标签:
1条回答
  • 2021-01-02 02:57

    Finally I found the solution to the problem.
    It was the context used in the row adapter. The constructor used is the shown in the following piece of code:

    public RowAdapter(Activity activity, ArrayList<String> list) {
        this.mContext = activity.getApplicationContext();
        this.elements = list;
        this.theActivity = activity;
    
        this.inflater = (LayoutInflater) this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    

    Just changing the context from:
    this.mContext = activity.getApplicationContext()(Application-Context)
    to
    this.mContext = activity.getBaseContext()(Activity-Context)
    solved the problem and now the background is the custom one.

    Whenever you need to manipulate Views then go for Activity-Context, else Application-Context would be enough.

    This answer helped me to understand why to use getBaseContext() instead of getApplicationContext() in my case.

    custom row background

    0 讨论(0)
提交回复
热议问题