use of android.widget.ToggleButton in project mobile-android by photo.
the class FeatherActivity method hideInfoScreen.
/**
* Hide info screen.
*/
private void hideInfoScreen() {
createInfoScreenAnimations(false);
mViewFlipper.setDisplayedChild(0);
View convertView = mWorkspace.getChildAt(mWorkspace.getChildCount() - 1);
if (null != convertView) {
View button = convertView.findViewById(R.id.tool_image);
if (button != null && button instanceof ToggleButton) {
((ToggleButton) button).setChecked(false);
}
}
}
use of android.widget.ToggleButton in project android_frameworks_base by ResurrectionRemix.
the class ElementLayoutActivity method createToggleButton.
private void createToggleButton() {
ToggleButton button = new ToggleButton(this);
button.setChecked(mRandom.nextBoolean());
mLayout.addView(button);
}
use of android.widget.ToggleButton in project JustAndroid by chinaltz.
the class AbExpandTabView method setData.
/**
* 设置tab item默认标题和内容View
*/
public void setData(List<String> tabTexts, List<View> contentViews) {
for (int i = 0; i < contentViews.size(); i++) {
View view = contentViews.get(i);
int maxHeight = (int) (displayHeight * 0.6);
RelativeLayout parentLayout = new RelativeLayout(context);
parentLayout.setBackgroundColor(Color.parseColor("#b0000000"));
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, maxHeight);
layoutParams.leftMargin = 0;
layoutParams.rightMargin = 0;
parentLayout.addView(view, layoutParams);
tabContentViews.add(parentLayout);
final ToggleButton tabButton = new ToggleButton(context);
tabButton.setGravity(Gravity.CENTER);
tabButton.setTextOn(null);
tabButton.setTextOff(null);
tabButton.setBackgroundResource(R.drawable.bg_tab_button);
tabButton.setTextColor(context.getResources().getColor(R.color.gray_content));
tabButton.setSingleLine(true);
//默认标题
tabButton.setText(tabTexts.get(i));
AbViewUtil.setTextSize(tabButton, 28);
addView(tabButton, new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
View line = new View(context);
line.setBackgroundResource(R.color.gray_line);
LayoutParams layoutParamsLine = new LayoutParams(1, LayoutParams.MATCH_PARENT);
layoutParamsLine.setMargins(0, 5, 0, 5);
if (i < contentViews.size() - 1) {
addView(line, layoutParamsLine);
}
//添加到列表
tabButtons.add(tabButton);
//用于判断位置
tabButton.setTag(i);
tabButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow == null || !popupWindow.isShowing()) {
currentTabButton = tabButton;
currentPosition = (Integer) currentTabButton.getTag();
showPopup(currentPosition);
} else {
dismissPopup();
}
}
});
tabButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (onCheckedChangedListener != null) {
onCheckedChangedListener.onCheckedChanged(currentPosition, isChecked);
}
}
});
}
}
use of android.widget.ToggleButton in project android_frameworks_base by crdroidandroid.
the class ElementLayoutActivity method createToggleButton.
private void createToggleButton() {
ToggleButton button = new ToggleButton(this);
button.setChecked(mRandom.nextBoolean());
mLayout.addView(button);
}
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")));
}
Aggregations