List of usage examples for android.widget CheckedTextView toggle
public void toggle()
From source file:Main.java
static public void setCheckedTextView(final CheckedTextView ctv) { ctv.setOnClickListener(new OnClickListener() { @Override/*from ww w. j a va2 s . co m*/ public void onClick(View v) { ctv.toggle(); } }); }
From source file:de.aw.monma.reports.ReportWPCats.java
@Override public void onBottomSheetItemClick(int arrayID, int position, Bundle extras, CheckedTextView view) { view.toggle(); if (view.isChecked()) { selectedWPTypen.add(position);//from w w w.j a v a 2 s.c om } else { selectedWPTypen.remove((Integer) position); } getAdapter().notifyDataSetChanged(); }
From source file:com.example.listviewanimationdemo.AnimateDismissActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animateremoval); mSelectedPositions = new ArrayList<Integer>(); ListView listView = (ListView) findViewById(R.id.activity_animateremoval_listview); mAdapter = new MyListAdapter(BaseListActivity.getItems()); final AnimateDismissAdapter animateDismissAdapter = new AnimateDismissAdapter(mAdapter, new MyOnDismissCallback()); animateDismissAdapter.setAbsListView(listView); listView.setAdapter(animateDismissAdapter); Button button = (Button) findViewById(R.id.activity_animateremoval_button); button.setOnClickListener(new OnClickListener() { @Override/*from ww w.j a v a2s. co m*/ public void onClick(final View v) { animateDismissAdapter.animateDismiss(mSelectedPositions); mSelectedPositions.clear(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { CheckedTextView tv = (CheckedTextView) view; tv.toggle(); if (tv.isChecked()) { mSelectedPositions.add(position); } else { mSelectedPositions.remove((Integer) position); } } }); }
From source file:com.example.listviewanimationdemo.itemmanipulation.AnimateDismissActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("item"); setContentView(R.layout.activity_animateremoval); mSelectedPositions = new ArrayList<Integer>(); ListView listView = (ListView) findViewById(R.id.activity_animateremoval_listview); mAdapter = new MyListAdapter(BaseListActivity.getItems()); final AnimateDismissAdapter animateDismissAdapter = new AnimateDismissAdapter(mAdapter, new MyOnDismissCallback()); animateDismissAdapter.setAbsListView(listView); listView.setAdapter(animateDismissAdapter); Button button = (Button) findViewById(R.id.activity_animateremoval_button); button.setOnClickListener(new OnClickListener() { @Override/*from www .j a v a 2 s. c o m*/ public void onClick(final View v) { animateDismissAdapter.animateDismiss(mSelectedPositions); mSelectedPositions.clear(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { CheckedTextView tv = (CheckedTextView) view; tv.toggle(); if (tv.isChecked()) { mSelectedPositions.add(position); } else { mSelectedPositions.remove((Integer) position); } } }); }
From source file:de.aw.monma.reports.FragmentSelectionListCatClass.java
@Override public void onRecyclerItemClick(View view, int position, long id) { super.onRecyclerItemClick(view, position, id); CheckedTextView cb = view.findViewById(R.id.tvSelection_item); cb.toggle(); if (cb.isChecked()) { excludedItems.remove(id);// w ww. j a v a 2 s . c om } else { excludedItems.add(id); } }
From source file:de.aw.monma.reports.FragmentSelectionListCat.java
@Override public void onRecyclerItemClick(View v, int position, Categorie item) { CheckedTextView cb = v.findViewById(R.id.tvSelection_item); cb.toggle(); boolean ausgeblendet = !cb.isChecked(); if (!ausgeblendet) { excludedItems.remove(item.getID()); } else {//w ww .java 2 s. c om excludedItems.add(item.getID()); } item.setAusgeblendet(ausgeblendet); if (item.isSuperCat()) { int pos = position + 1; Categorie cat = getAdapter().get(pos); while (cat.isSuperCatMember(item.getID())) { if (!ausgeblendet) { excludedItems.remove(cat.getID()); } else { excludedItems.add(cat.getID()); } cat.setAusgeblendet(ausgeblendet); pos++; cat = getAdapter().get(pos); } } super.onRecyclerItemClick(v, position, item); }
From source file:com.sentaroh.android.Utilities.Dialog.SafFileSelectDialogFragment.java
static private void setCheckedTextView(final CheckedTextView ctv) { ctv.setOnClickListener(new OnClickListener() { @Override// w w w . ja v a 2 s .c o m public void onClick(View v) { ctv.toggle(); } }); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number, boolean scan_start) { //??/*from w w w. ja v a2s . c o m*/ final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.scan_remote_ntwk_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_title_view); final TextView title = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok); final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel); final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_msg); final TextView tv_result = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_title); tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_press_scan_btn)); tv_result.setVisibility(TextView.GONE); final String from = CommonUtilities.getLocalIpAddress(); String subnet = from.substring(0, from.lastIndexOf(".")); String subnet_o1, subnet_o2, subnet_o3; subnet_o1 = subnet.substring(0, subnet.indexOf(".")); subnet_o2 = subnet.substring(subnet.indexOf(".") + 1, subnet.lastIndexOf(".")); subnet_o3 = subnet.substring(subnet.lastIndexOf(".") + 1, subnet.length()); final EditText baEt1 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o1); final EditText baEt2 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o2); final EditText baEt3 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o3); final EditText baEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o4); final EditText eaEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_end_address_o4); baEt1.setText(subnet_o1); baEt2.setText(subnet_o2); baEt3.setText(subnet_o3); baEt4.setText("1"); baEt4.setSelection(1); eaEt4.setText("254"); baEt4.requestFocus(); final CheckedTextView ctv_use_port_number = (CheckedTextView) dialog .findViewById(R.id.scan_remote_ntwk_ctv_use_port); final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number); CommonDialog.setDlgBoxSizeLimit(dialog, true); if (port_number.equals("")) { et_port_number.setEnabled(false); ctv_use_port_number.setChecked(false); } else { et_port_number.setEnabled(true); et_port_number.setText(port_number); ctv_use_port_number.setChecked(true); } ctv_use_port_number.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctv_use_port_number.toggle(); boolean isChecked = ctv_use_port_number.isChecked(); et_port_number.setEnabled(isChecked); } }); final NotifyEvent ntfy_lv_click = new NotifyEvent(mContext); ntfy_lv_click.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { dialog.dismiss(); p_ntfy.notifyToListener(true, o); } @Override public void negativeResponse(Context c, Object[] o) { } }); final ArrayList<ScanAddressResultListItem> ipAddressList = new ArrayList<ScanAddressResultListItem>(); // ScanAddressResultListItem li=new ScanAddressResultListItem(); // li.server_name=mContext.getString(R.string.msgs_ip_address_no_address); // ipAddressList.add(li); final ListView lv = (ListView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_list); final AdapterScanAddressResultList adap = new AdapterScanAddressResultList(mContext, R.layout.scan_address_result_list_item, ipAddressList, ntfy_lv_click); lv.setAdapter(adap); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); //SCAN? btn_scan.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ipAddressList.clear(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { if (ipAddressList.size() < 1) { tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_not_detected)); tv_result.setVisibility(TextView.GONE); } else { tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_select_detected_host)); tv_result.setVisibility(TextView.VISIBLE); } // adap.clear(); // for (int i=0;i<ipAddressList.size();i++) // adap.add(ipAddressList.get(i)); } @Override public void negativeResponse(Context c, Object[] o) { } }); if (auditScanAddressRangeValue(dialog)) { tv_result.setVisibility(TextView.GONE); String ba1 = baEt1.getText().toString(); String ba2 = baEt2.getText().toString(); String ba3 = baEt3.getText().toString(); String ba4 = baEt4.getText().toString(); String ea4 = eaEt4.getText().toString(); String subnet = ba1 + "." + ba2 + "." + ba3; int begin_addr = Integer.parseInt(ba4); int end_addr = Integer.parseInt(ea4); scanRemoteNetwork(dialog, lv, adap, ipAddressList, subnet, begin_addr, end_addr, ntfy); } else { //error } } }); //CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); if (scan_start) btn_scan.performClick(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void promptPasswordForExport(final String fpath, final NotifyEvent ntfy_pswd) { // ??//from w ww .j a v a 2 s . c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.password_input_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.password_input_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.password_input_title_view); final TextView title = (TextView) dialog.findViewById(R.id.password_input_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.password_input_msg); final CheckedTextView ctv_protect = (CheckedTextView) dialog.findViewById(R.id.password_input_ctv_protect); final Button btn_ok = (Button) dialog.findViewById(R.id.password_input_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.password_input_cancel_btn); final EditText et_password = (EditText) dialog.findViewById(R.id.password_input_password); final EditText et_confirm = (EditText) dialog.findViewById(R.id.password_input_password_confirm); dlg_msg.setText(mContext.getString(R.string.msgs_export_import_pswd_specify_password)); CommonDialog.setDlgBoxSizeCompact(dialog); ctv_protect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctv_protect.toggle(); boolean isChecked = ctv_protect.isChecked(); setPasswordFieldVisibility(isChecked, et_password, et_confirm, btn_ok, dlg_msg); } }); ctv_protect.setChecked(mGp.settingExportedProfileEncryptRequired); setPasswordFieldVisibility(mGp.settingExportedProfileEncryptRequired, et_password, et_confirm, btn_ok, dlg_msg); et_password.setEnabled(true); et_confirm.setEnabled(false); et_password.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { btn_ok.setEnabled(false); setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); et_confirm.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { btn_ok.setEnabled(false); setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); //OK button btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String passwd = et_password.getText().toString(); if ((ctv_protect.isChecked() && !mGp.settingExportedProfileEncryptRequired) || (!ctv_protect.isChecked() && mGp.settingExportedProfileEncryptRequired)) { mGp.settingExportedProfileEncryptRequired = ctv_protect.isChecked(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); prefs.edit().putBoolean(mContext.getString(R.string.settings_exported_profile_encryption), ctv_protect.isChecked()).commit(); } if (!ctv_protect.isChecked()) { dialog.dismiss(); ntfy_pswd.notifyToListener(true, new Object[] { "" }); } else { if (!passwd.equals(et_confirm.getText().toString())) { //Unmatch dlg_msg.setText( mContext.getString(R.string.msgs_export_import_pswd_unmatched_confirm_pswd)); } else { dialog.dismiss(); ntfy_pswd.notifyToListener(true, new Object[] { passwd }); } } } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); ntfy_pswd.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setCancelable(false); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); dialog.show(); }