use of android.widget.ToggleButton in project ExpandTabView by yueyueniao2012.
the class ExpandTabView method setValue.
/**
* 设置tabitem的个数和初始值
*/
public void setValue(ArrayList<String> textArray, ArrayList<View> viewArray) {
if (mContext == null) {
return;
}
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mTextArray = textArray;
for (int i = 0; i < viewArray.size(); i++) {
final RelativeLayout r = new RelativeLayout(mContext);
int maxHeight = (int) (displayHeight * 0.7);
RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, maxHeight);
rl.leftMargin = 10;
rl.rightMargin = 10;
r.addView(viewArray.get(i), rl);
mViewArray.add(r);
r.setTag(SMALL);
ToggleButton tButton = (ToggleButton) inflater.inflate(R.layout.toggle_button, this, false);
addView(tButton);
View line = new TextView(mContext);
line.setBackgroundResource(R.drawable.choosebar_line);
if (i < viewArray.size() - 1) {
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(2, LinearLayout.LayoutParams.FILL_PARENT);
addView(line, lp);
}
mToggleButton.add(tButton);
tButton.setTag(i);
tButton.setText(mTextArray.get(i));
r.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onPressBack();
}
});
r.setBackgroundColor(mContext.getResources().getColor(R.color.popup_main_background));
tButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// initPopupWindow();
ToggleButton tButton = (ToggleButton) view;
if (selectedButton != null && selectedButton != tButton) {
selectedButton.setChecked(false);
}
selectedButton = tButton;
selectPosition = (Integer) selectedButton.getTag();
startAnimation();
if (mOnButtonClickListener != null && tButton.isChecked()) {
mOnButtonClickListener.onClick(selectPosition);
}
}
});
}
}
use of android.widget.ToggleButton in project little-bear-dictionary by daimajia.
the class OfflineListCursorAdapter method bindView.
@Override
public void bindView(View convertView, Context context, Cursor cursor) {
TextView dictionary_name_textView = (TextView) convertView.findViewById(R.id.item_dictionary_name);
TextView dictionary_size = (TextView) convertView.findViewById(R.id.item_dictionary_size);
ToggleButton toggleButton = (ToggleButton) convertView.findViewById(R.id.item_hide);
Boolean isShow = cursor.getInt(cursor.getColumnIndex("dictionary_show")) == 1 ? true : false;
toggleButton.setChecked(isShow);
toggleButton.setContentDescription(cursor.getString(cursor.getColumnIndex("_id")));
toggleButton.setOnCheckedChangeListener(this);
dictionary_name_textView.setText(cursor.getString(cursor.getColumnIndex("dictionary_name")));
dictionary_size.setText(cursor.getString(cursor.getColumnIndex("dictionary_size")));
}
use of android.widget.ToggleButton in project butterknife by JakeWharton.
the class OnCheckedChangedTest method argumentCast.
@UiThreadTest
@Test
public void argumentCast() {
class MyView extends ToggleButton implements ArgumentCast.MyInterface {
MyView(Context context) {
super(context);
}
}
View view1 = new MyView(InstrumentationRegistry.getContext());
view1.setId(1);
View view2 = new MyView(InstrumentationRegistry.getContext());
view2.setId(2);
View view3 = new MyView(InstrumentationRegistry.getContext());
view3.setId(3);
ViewGroup tree = new FrameLayout(InstrumentationRegistry.getContext());
tree.addView(view1);
tree.addView(view2);
tree.addView(view3);
ArgumentCast target = new ArgumentCast();
ButterKnife.bind(target, tree);
view1.performClick();
assertSame(view1, target.last);
view2.performClick();
assertSame(view2, target.last);
view3.performClick();
assertSame(view3, target.last);
}
Aggregations