Example usage for android.widget TabWidget getContext

List of usage examples for android.widget TabWidget getContext

Introduction

In this page you can find the example usage for android.widget TabWidget getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

static boolean updateButtonBar(Activity a, int highlight) {
    final TabWidget ll = (TabWidget) a.findViewById(R.id.buttonbar);
    boolean withtabs = false;
    Intent intent = a.getIntent();/* w  w  w. j a v  a 2 s. c  o  m*/
    if (intent != null) {
        withtabs = intent.getBooleanExtra("withtabs", false);
    }

    if (highlight == 0 || !withtabs) {
        ll.setVisibility(View.GONE);
        return withtabs;
    } else if (withtabs) {
        ll.setVisibility(View.VISIBLE);
    }
    for (int i = ll.getChildCount() - 1; i >= 0; i--) {

        View v = ll.getChildAt(i);
        boolean isActive = (v.getId() == highlight);
        if (isActive) {
            ll.setCurrentTab(i);
            sActiveTabIndex = i;
        }
        v.setTag(i);
        v.setOnFocusChangeListener(new View.OnFocusChangeListener() {

            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    for (int i = 0; i < ll.getTabCount(); i++) {
                        if (ll.getChildTabViewAt(i) == v) {
                            ll.setCurrentTab(i);
                            processTabClick((Activity) ll.getContext(), v,
                                    ll.getChildAt(sActiveTabIndex).getId());
                            break;
                        }
                    }
                }
            }
        });

        v.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                processTabClick((Activity) ll.getContext(), v, ll.getChildAt(sActiveTabIndex).getId());
            }
        });
    }
    return withtabs;
}