Invisible ActionMode item icons in Theme.Sherlock.Light.DarkActionBar

前端 未结 8 2446
一生所求
一生所求 2021-02-13 09:47

When using Theme.Sherlock.Light.DarkActionBar (or Theme.Holo.Light.DarkActionBar, doesn\'t make a difference), the ActionMode (or \"contextual ActionB

8条回答
  •  清酒与你
    2021-02-13 10:07

    I was fighting with the same issue since last two days. Finally I came up with a workaround!

    I am using a DialogFragment with an AlertDialog object. In the onCreateDialog() method, all we have to do is get the context of the parent activity and set its theme again to Theme.Light.

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        //get the parent activity context and set it's theme again.
        Context ctx = getActivity();
        ctx.setTheme(android.R.style.Theme_Holo_Light);
        AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.your_dialog_layout, null, false);
        builder.setView(view);
    
        //your other code for the dialog
        //
    
        return builder.create();
    

    Now the icons in the Contextual ActionBar of the EditText have the right color.

提交回复
热议问题