Android Processing view

We sometimes see processing view, which is a bit black shadow. 日本語

It indicates can’t touch UI and processing something in background.

There aren’t that kind of view by default(Progress bar or indicator exist).

I made following using View class.

black

1. Create Layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#80000000">
</LinearLayout>

Add only LenearView with transparent black background.

2. Use this view on Acitivity

public class BlackViewActivity extends Activity 
{
     
    private View blackView;
 
    private boolean black=false;
     
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
         
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
         
        blackView = getLayoutInflater().inflate(R.layout.shadow, null);
        blackView.setClickable(false); // No?
        blackView.setVisibility(View.INVISIBLE);
        addContentView(blackView, new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
    }
 
    @Override
    public boolean onOptionsItemSelected(MenuItem item) 
    {
        switch (item.getItemId()) 
        {
        case android.R.id.home:
            if ( !black )
            {
                showBlack();
                black = true;
            }
            else
            {
                hideBlack();
                black = false;
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
 
    private void showBlack() 
    {
        blackView.setVisibility(View.VISIBLE);
    }
     
    private void hideBlack()
    {
        blackView.setVisibility(View.INVISIBLE);
    }
}

Use actionbar to switch view for testing.