Example usage for android.widget TabWidget setDividerDrawable

List of usage examples for android.widget TabWidget setDividerDrawable

Introduction

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

Prototype

public void setDividerDrawable(@DrawableRes int resId) 

Source Link

Document

Sets the drawable to use as a divider between the tab indicators.

Usage

From source file:com.ustc.dystu.dandelion.fragment.BaseFragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();//  w w w  . ja  v  a 2 s  .c o  m

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        tw.setDividerDrawable(null);//?ab?
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:org.mozilla.gecko.AwesomeBar.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d(LOGTAG, "creating awesomebar");

    mResolver = Tabs.getInstance().getContentResolver();

    setContentView(R.layout.awesomebar);

    if (Build.VERSION.SDK_INT >= 11) {
        RelativeLayout actionBarLayout = (RelativeLayout) GeckoActionBar.getCustomView(this);
        mGoButton = (ImageButton) actionBarLayout.findViewById(R.id.awesomebar_button);
        mText = (AwesomeBarEditText) actionBarLayout.findViewById(R.id.awesomebar_text);
    } else {/* ww  w .j  av a  2s  .c o  m*/
        mGoButton = (ImageButton) findViewById(R.id.awesomebar_button);
        mText = (AwesomeBarEditText) findViewById(R.id.awesomebar_text);
    }

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    tabWidget.setDividerDrawable(null);

    mAwesomeTabs = (AwesomeBarTabs) findViewById(R.id.awesomebar_tabs);
    mAwesomeTabs.setOnUrlOpenListener(new AwesomeBarTabs.OnUrlOpenListener() {
        public void onUrlOpen(String url) {
            openUrlAndFinish(url);
        }

        public void onSearch(String engine) {
            openSearchAndFinish(mText.getText().toString(), engine);
        }
    });

    mGoButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            openUserEnteredAndFinish(mText.getText().toString());
        }
    });

    Resources resources = getResources();

    int padding[] = { mText.getPaddingLeft(), mText.getPaddingTop(), mText.getPaddingRight(),
            mText.getPaddingBottom() };

    GeckoStateListDrawable states = new GeckoStateListDrawable();
    states.initializeFilter(GeckoApp.mBrowserToolbar.getHighlightColor());
    states.addState(new int[] { android.R.attr.state_focused },
            resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] { android.R.attr.state_pressed },
            resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] {}, resources.getDrawable(R.drawable.address_bar_url_default));
    mText.setBackgroundDrawable(states);

    mText.setPadding(padding[0], padding[1], padding[2], padding[3]);

    Intent intent = getIntent();
    String currentUrl = intent.getStringExtra(CURRENT_URL_KEY);
    mType = intent.getStringExtra(TYPE_KEY);
    if (currentUrl != null) {
        mText.setText(currentUrl);
        mText.selectAll();
    }

    mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() {
        public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
            // We only want to process one event per tap
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;

            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                openUserEnteredAndFinish(mText.getText().toString());
                return true;
            }

            // If input method is in fullscreen mode, we want to dismiss
            // it instead of closing awesomebar straight away.
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (keyCode == KeyEvent.KEYCODE_BACK && !imm.isFullscreenMode()) {
                // Let mAwesomeTabs try to handle the back press, since we may be in a
                // bookmarks sub-folder.
                if (mAwesomeTabs.onBackPressed())
                    return true;

                // If mAwesomeTabs.onBackPressed() returned false, we didn't move up
                // a folder level, so just exit the activity.
                cancelAndFinish();
                return true;
            }

            return false;
        }
    });

    mText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            // do nothing
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // do nothing
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String text = s.toString();

            mAwesomeTabs.filter(text);
            updateGoButton(text);
        }
    });

    mText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() != KeyEvent.ACTION_DOWN)
                    return true;

                openUserEnteredAndFinish(mText.getText().toString());
                return true;
            } else {
                return false;
            }
        }
    });

    mText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }
    });

    registerForContextMenu(mAwesomeTabs.findViewById(R.id.all_pages_list));
    registerForContextMenu(mAwesomeTabs.findViewById(R.id.bookmarks_list));
    registerForContextMenu(mAwesomeTabs.findViewById(R.id.history_list));

    GeckoAppShell.registerGeckoEventListener("SearchEngines:Data", this);
    GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:Get", null));
}