mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
037fe6c066
--HG-- extra : rebase_source : d98af982cea4c526070f03f647dc668013a0b1d5
61 lines
1.7 KiB
Java
61 lines
1.7 KiB
Java
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.widget;
|
|
|
|
import org.mozilla.gecko.R;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.widget.ImageButton;
|
|
import android.widget.TabWidget;
|
|
|
|
public class IconTabWidget extends TabWidget {
|
|
private Context mContext;
|
|
private OnTabChangedListener mListener;
|
|
|
|
public static interface OnTabChangedListener {
|
|
public void onTabChanged(int tabIndex);
|
|
}
|
|
|
|
public IconTabWidget(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
mContext = context;
|
|
}
|
|
|
|
public ImageButton addTab(int resId) {
|
|
ImageButton button = (ImageButton) LayoutInflater.from(mContext).inflate(R.layout.tabs_panel_indicator, null);
|
|
button.setImageResource(resId);
|
|
|
|
addView(button);
|
|
button.setOnClickListener(new TabClickListener(getTabCount() - 1));
|
|
button.setOnFocusChangeListener(this);
|
|
return button;
|
|
}
|
|
|
|
public void setTabSelectionListener(OnTabChangedListener listener) {
|
|
mListener = listener;
|
|
}
|
|
|
|
@Override
|
|
public void onFocusChange(View view, boolean hasFocus) {
|
|
}
|
|
|
|
private class TabClickListener implements OnClickListener {
|
|
private final int mIndex;
|
|
|
|
public TabClickListener(int index) {
|
|
mIndex = index;
|
|
}
|
|
|
|
@Override
|
|
public void onClick(View view) {
|
|
if (mListener != null)
|
|
mListener.onTabChanged(mIndex);
|
|
}
|
|
}
|
|
}
|