@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bstacInstance = Beaconstac.getInstance(this); bstacInstance.setRegionParams( "F94DBB23-2266-7822-3782-57BEAC0952AC", "com.mobstac.beaconstacexample"); bstacInstance.syncRules(); try { bstacInstance.startRangingBeacons(); } catch (MSException e) { e.printStackTrace(); } button1 = (RadioButton) findViewById(R.id.button_home); button1.setOnCheckedChangeListener(this); button2 = (RadioButton) findViewById(R.id.button_messages); button2.setOnCheckedChangeListener(this); button3 = (RadioButton) findViewById(R.id.button_settings); button3.setOnCheckedChangeListener(this); button4 = (RadioButton) findViewById(R.id.button_todolist); button4.setOnCheckedChangeListener(this); if (savedInstanceState == null) { registerBroadcast(); } actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#03A9F4"))); fragmentManager = getSupportFragmentManager(); button1.setChecked(true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_payment); clazz = (ClassInfoBean) getIntent().getExtras().getSerializable("CLAZZ"); if (clazz == null) { finish(); } setTitle(R.string.title_clazz_payment); ((Button) findViewById(R.id.back)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { finish(); } }); mTab1 = (RadioButton) findViewById(R.id.radio1); mTab2 = (RadioButton) findViewById(R.id.radio2); mTab1.setText("创建缴费"); mTab2.setText("已建缴费"); mContainer = (FrameLayout) findViewById(R.id.content); mTab1.setOnCheckedChangeListener(this); mTab2.setOnCheckedChangeListener(this); mTab1.performClick(); }
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fragment = inflater.inflate(R.layout.fragment_definition, container, false); prefs = getActivity().getSharedPreferences("Taminations", Context.MODE_PRIVATE); defview = (WebView) fragment.findViewById(R.id.definitionView); // Turn on pinch-to-zoom, which is off(!) by default defview.getSettings().setBuiltInZoomControls(true); defview.getSettings().setJavaScriptEnabled(true); abbrevRadioButton = (RadioButton) fragment.findViewById(R.id.definitionAbbrevRadioButton); abbrevRadioButton.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { evaluateJavascript("setAbbrev(true)"); prefs.edit().putBoolean("isabbrev", true).commit(); } } }); fullRadioButton = (RadioButton) fragment.findViewById(R.id.definitionFullRadioButton); fullRadioButton.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { evaluateJavascript("setAbbrev(false)"); prefs.edit().putBoolean("isabbrev", false).commit(); } } }); setDefinition(intentString("link")); return fragment; }
private void initRadioBtnEvent() { // artworkPicRB.setOnCheckedChangeListener(); artworkPicRB.setOnCheckedChangeListener( new CommonOnCheckedChangeListener(this, artworkPicRB) {}); middlePicRB.setOnCheckedChangeListener(new CommonOnCheckedChangeListener(this, middlePicRB) {}); smallPicRB.setOnCheckedChangeListener(new CommonOnCheckedChangeListener(this, smallPicRB) {}); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.actnavbar); RadioButton radioButton; radioButton = (RadioButton) findViewById(R.id.btnAll); radioButton.setOnCheckedChangeListener(btnNavBarOnCheckedChangeListener); radioButton = (RadioButton) findViewById(R.id.btnPicture); radioButton.setOnCheckedChangeListener(btnNavBarOnCheckedChangeListener); radioButton = (RadioButton) findViewById(R.id.btnVideo); radioButton.setOnCheckedChangeListener(btnNavBarOnCheckedChangeListener); radioButton = (RadioButton) findViewById(R.id.btnFile); radioButton.setOnCheckedChangeListener(btnNavBarOnCheckedChangeListener); }
public void generateTransferEntrys() { for (int i = 0; i < tranGroup.getChildCount(); i++) { RadioButton radioButton = (RadioButton) tranGroup.getChildAt(i); radioButton.setOnCheckedChangeListener(this); } }
private RadioButton initRadioButton(View v, int viewId, final byte fileType) { final RadioButton button = findView(v, viewId); final Resources r = button.getResources(); final FileTypeRadioButtonSelectorFactory fileTypeRadioButtonSelectorFactory = new FileTypeRadioButtonSelectorFactory( fileType, r, FileTypeRadioButtonSelectorFactory.RadioButtonContainerType.BROWSE); fileTypeRadioButtonSelectorFactory.updateButtonBackground(button); button.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (button.isChecked()) { browseFilesButtonClick(fileType); } fileTypeRadioButtonSelectorFactory.updateButtonBackground(button); } }); button.setOnCheckedChangeListener( new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { browseFilesButtonClick(fileType); } fileTypeRadioButtonSelectorFactory.updateButtonBackground(button); } }); button.setChecked(fileType == Constants.FILE_TYPE_AUDIO); return button; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add); mImage = (ImageButton) findViewById(R.id.image); mIssuer = (EditText) findViewById(R.id.issuer); mLabel = (EditText) findViewById(R.id.label); mSecret = (EditText) findViewById(R.id.secret); mInterval = (EditText) findViewById(R.id.interval); mCounter = (EditText) findViewById(R.id.counter); mAlgorithm = (Spinner) findViewById(R.id.algorithm); mHOTP = (RadioButton) findViewById(R.id.hotp); // Select the default algorithm mAlgorithm.setSelection(SHA1_OFFSET); // Setup the Counter toggle mHOTP.setOnCheckedChangeListener(this); // Setup the buttons findViewById(R.id.cancel).setOnClickListener(this); findViewById(R.id.add).setOnClickListener(this); findViewById(R.id.add).setEnabled(false); mImage.setOnClickListener(this); // Set constraints on when the Add button is enabled TextWatcher tw = new AddTextWatcher(this); mIssuer.addTextChangedListener(tw); mLabel.addTextChangedListener(tw); mSecret.addTextChangedListener(new AddSecretTextWatcher(this)); mInterval.addTextChangedListener(tw); }
private void init() { LayoutInflater.from(getContext()).inflate(R.layout.place_dialog_filter, this); ButterKnife.inject(this, this); costAll.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) costType = -1; }); costFree.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) costType = 0; }); costWeight.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) costType = 1; }); costTime.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) costType = 2; }); poolAll.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) poolType = -1; }); poolPond.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) poolType = 0; }); poolReservoir.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) poolType = 1; }); poolRiver.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) poolType = 2; }); poolLake.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) poolType = 3; }); poolOcean.setOnCheckedChangeListener( (buttonView, isChecked) -> { if (isChecked) poolType = 4; }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } view = inflater.inflate(R.layout.add_point_interet, container, false); Button b = (Button) view.findViewById(R.id.buttonPhoto); Button bAdd = (Button) view.findViewById(R.id.buttonAddPoint); cRecy = (CheckBox) view.findViewById(R.id.checkBoxRecy); rPoint = (RadioButton) view.findViewById(R.id.radioButtonPoint); rZone = (RadioButton) view.findViewById(R.id.radioButtonZone); b.setOnClickListener(this); bAdd.setOnClickListener(this); cRecy.setOnClickListener(this); rPoint.setOnCheckedChangeListener(this); rZone.setOnCheckedChangeListener(this); textViewType = (TextView) view.findViewById(R.id.textViewType); textViewType.setVisibility(View.INVISIBLE); spinnerTag = (Spinner) view.findViewById(R.id.spinnerTag); spinnerTag.setVisibility(View.INVISIBLE); pref = new Preferences(this.getActivity()); if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this.getActivity()) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViews(); radioButton_lcty.setOnCheckedChangeListener(listener); radioButton_wzty.setOnCheckedChangeListener(listener); radioButton_xzty.setOnCheckedChangeListener(listener); radioButton_shak_i_like.setOnCheckedChangeListener(listener); adapter_lcty = new MainIconAdapter(AppConstant.title_lcty, AppConstant.imageIcon_lcty, this); adapter_wzty = new MainIconAdapter(AppConstant.title_wzty, AppConstant.imageIcon_wzty, this); adapter_xzty = new MainIconAdapter(AppConstant.title_xzty, AppConstant.imageIcon_xzty, this); gridView.setAdapter(adapter_lcty); // 默认适配器 // 为单个Item添加单击事件。 gridView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(MainActivity.this, ChildActivity.class); // 传递对应的位置, 直接传递的是R中layout对应的int值 if (adapter_lcty == gridView.getAdapter()) { intent.putExtra("id", AppConstant.layout_lcty[position]); } else if (adapter_wzty == gridView.getAdapter()) { intent.putExtra("id", AppConstant.layout_wzty[position]); } else if (adapter_xzty == gridView.getAdapter()) { intent.putExtra("id", AppConstant.layout_xzty[position]); } startActivity(intent); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pay_select); final RadioButton zhifubaoRb = (RadioButton) findViewById(R.id.zhifubao_rb); Button payConfirmButton = (Button) findViewById(R.id.pay_confirm_button); zhifubaoRb.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {} }); payConfirmButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // if (zhifubaoRb.isChecked()) {} } }); }
public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); LayoutInflater inflater = LayoutInflater.from(getContext()); // SurveyCTO-added support for dynamic select content (from .csv files) XPathFuncExpr xPathFuncExpr = ExternalDataUtil.getSearchXPathExpression(prompt.getAppearanceHint()); if (xPathFuncExpr != null) { mItems = ExternalDataUtil.populateExternalChoices(prompt, xPathFuncExpr); } else { mItems = prompt.getSelectChoices(); } buttons = new ArrayList<RadioButton>(); listener = (AdvanceToNextListener) context; String s = null; if (prompt.getAnswerValue() != null) { s = ((Selection) prompt.getAnswerValue().getValue()).getValue(); } // use this for recycle Bitmap b = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.expander_ic_right); if (mItems != null) { for (int i = 0; i < mItems.size(); i++) { RelativeLayout thisParentLayout = (RelativeLayout) inflater.inflate(R.layout.quick_select_layout, null); LinearLayout questionLayout = (LinearLayout) thisParentLayout.getChildAt(0); ImageView rightArrow = (ImageView) thisParentLayout.getChildAt(1); RadioButton r = new RadioButton(getContext()); r.setText(prompt.getSelectChoiceText(mItems.get(i))); r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); r.setTag(Integer.valueOf(i)); r.setId(QuestionWidget.newUniqueId()); r.setEnabled(!prompt.isReadOnly()); r.setFocusable(!prompt.isReadOnly()); rightArrow.setImageBitmap(b); buttons.add(r); if (mItems.get(i).getValue().equals(s)) { r.setChecked(true); } r.setOnCheckedChangeListener(this); String audioURI = null; audioURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO); String imageURI; if (mItems.get(i) instanceof ExternalSelectChoice) { imageURI = ((ExternalSelectChoice) mItems.get(i)).getImage(); } else { imageURI = prompt.getSpecialFormSelectChoiceText( mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE); } String videoURI = null; videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video"); String bigImageURI = null; bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image"); MediaLayout mediaLayout = new MediaLayout(getContext()); mediaLayout.setAVT(prompt.getIndex(), "", r, audioURI, imageURI, videoURI, bigImageURI); if (i != mItems.size() - 1) { // Last, add the dividing line (except for the last element) ImageView divider = new ImageView(getContext()); divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright); mediaLayout.addDivider(divider); } questionLayout.addView(mediaLayout); addView(thisParentLayout); } } }
public SelectOneWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); // SurveyCTO-added support for dynamic select content (from .csv files) XPathFuncExpr xPathFuncExpr = ExternalDataUtil.getSearchXPathExpression(prompt.getAppearanceHint()); if (xPathFuncExpr != null) { mItems = ExternalDataUtil.populateExternalChoices(prompt, xPathFuncExpr); } else { mItems = prompt.getSelectChoices(); } buttons = new ArrayList<RadioButton>(); // Layout holds the vertical list of buttons LinearLayout buttonLayout = new LinearLayout(context); String s = null; if (prompt.getAnswerValue() != null) { s = ((Selection) prompt.getAnswerValue().getValue()).getValue(); } if (mItems != null) { for (int i = 0; i < mItems.size(); i++) { RadioButton r = new RadioButton(getContext()); r.setText(prompt.getSelectChoiceText(mItems.get(i))); r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); r.setTag(Integer.valueOf(i)); r.setId(QuestionWidget.newUniqueId()); r.setEnabled(!prompt.isReadOnly()); r.setFocusable(!prompt.isReadOnly()); buttons.add(r); if (mItems.get(i).getValue().equals(s)) { r.setChecked(true); } r.setOnCheckedChangeListener(this); String audioURI = null; audioURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO); String imageURI; if (mItems.get(i) instanceof ExternalSelectChoice) { imageURI = ((ExternalSelectChoice) mItems.get(i)).getImage(); } else { imageURI = prompt.getSpecialFormSelectChoiceText( mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE); } String videoURI = null; videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video"); String bigImageURI = null; bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image"); MediaLayout mediaLayout = new MediaLayout(getContext()); mediaLayout.setAVT( prompt.getIndex(), "." + Integer.toString(i), r, audioURI, imageURI, videoURI, bigImageURI); if (i != mItems.size() - 1) { // Last, add the dividing line (except for the last element) ImageView divider = new ImageView(getContext()); divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright); mediaLayout.addDivider(divider); } buttonLayout.addView(mediaLayout); } } buttonLayout.setOrientation(LinearLayout.VERTICAL); // The buttons take up the right half of the screen LayoutParams buttonParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); addView(buttonLayout, buttonParams); }
/** * 单复式投注调用函数 * * @param string 显示框信息 * @return */ public void alert(String string, final String zhuma) { codeStr = zhuma; isGift = false; isJoin = false; isTouzhu = true; LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.alert_dialog_touzhu, null); LinearLayout layout = (LinearLayout) v.findViewById(R.id.alert_dialog_touzhu_linear_qihao_beishu); layout.setVisibility(LinearLayout.GONE); final AlertDialog dialog = new AlertDialog.Builder(this).setTitle("您选择的是").create(); dialog.show(); TextView text = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_one); text.setText(string); TextView textZhuma = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma); textZhuma.setText(zhuma); Button cancel = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_cancel); Button ok = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_ok); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog.cancel(); } }); ok.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); initBetPojo(); // TODO Auto-generated method stub if (isGift) { toActivity(zhuma); } else if (isJoin) { toJoinActivity(); } else if (isTouzhu) { touZhuNet(); } } }); check = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu_check); joinCheck = (RadioButton) v.findViewById(R.id.alert_dialog_join_check); RadioButton touzhuCheck = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu1_check); touzhuCheck.setChecked(true); TextView textAlert = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_alert); check.setPadding(50, 0, 0, 0); check.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 check.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isGift = isChecked; } }); joinCheck.setPadding(50, 0, 0, 0); joinCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 joinCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isJoin = isChecked; } }); touzhuCheck.setPadding(50, 0, 0, 0); touzhuCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 touzhuCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isTouzhu = isChecked; } }); dialog.getWindow().setContentView(v); }
/** * 加载每一行的单选按钮 * * @param layoutMain * @param line * @param lineNum */ private void addLine( LinearLayout layoutMain, int line, int lineNum, int isDanNum, int danTeamNum, int teamNum, final boolean isBeijing) { LinearLayout layoutOne = new LinearLayout(context); int id = 0; int last = getNum(teamNum - 1, true); boolean isCheck = isLastCheck(teamNum, danTeamNum); for (int j = 0; j < lineNum; j++) { id = line * this.LineNum + j; RadioButton radio = new RadioButton(context); if (id < isDanNum) { radio.setEnabled(false); radio.setTextColor(Color.GRAY); radio.setButtonDrawable(R.drawable.radio_select); } else if (!isCheck && id >= last) { radio.setEnabled(false); radio.setTextColor(Color.GRAY); radio.setButtonDrawable(R.drawable.radio_select); } else { radio.setTextColor(Color.BLACK); radio.setButtonDrawable(R.drawable.radio_select); } if (isBeijing) { radio.setText(beijingTextId[id]); } else { radio.setText(radioTextId[id]); } int width = PublicMethod.getDisplayWidth(context); if (width == 720) { radio.setTextSize(PublicMethod.getPxInt(7, context)); } else if (width == 640) { radio.setTextSize(PublicMethod.getPxInt(7, context)); } else if (width == 240) { radio.setTextSize(PublicMethod.getPxInt(20, context)); } else if (width == 320) { radio.setTextSize(PublicMethod.getPxInt(15, context)); } else if (width == 800) { radio.setTextSize(PublicMethod.getPxInt(8, context)); } else { radio.setTextSize(PublicMethod.getPxInt(10, context)); } if (Constants.SCREEN_HEIGHT == 854) { radio.setTextSize(PublicMethod.getPxInt(8, context)); } radio.setId(id); radio.setPadding(PublicMethod.getPxInt(20, context), 0, 0, 0); int withPx = PublicMethod.getPxInt(75, context); // 将dip换算成px radio.setLayoutParams(new LayoutParams(withPx, LayoutParams.WRAP_CONTENT)); radio.setOnCheckedChangeListener( new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (isBeijing) { ((BeiJingSingleGameIndentActivity) context).bettingNum = getBeijingRadioZhu(buttonView.getText().toString()); ((BeiJingSingleGameIndentActivity) context).setBettingInformationShow(); } else { touzhuDialog.zhuShu = getRadioZhu(buttonView.getText().toString()); touzhuDialog.setAlertText(); setRadioPrize(buttonView.getText().toString()); } clearRadio(buttonView); } } }); radioBtns.add(radio); layoutOne.addView(radio); } layoutMain.addView(layoutOne); }
public void createRadioButtons(int[] order, DatabaseQuestion question, boolean[] intialState) { int numberOfButtons = question.allOptionsLength(); String[] optionsToDisplay = new String[numberOfButtons]; radioButtons = new RadioButton[numberOfButtons]; if (intialState == null) { intialState = new boolean[numberOfButtons]; } if (order == null) { order = new int[numberOfButtons]; for (int i = 0; i < numberOfButtons; i++) { order[i] = i; } } this.answerLocations.clear(); String[] tempAnswer = question.getAnswer(); for (int i = 0; i < question.getAnswer().length; i++) { answerLocations.add(order[i]); optionsToDisplay[order[i]] = tempAnswer[i]; } String[] tempOption = question.getOptionsArray(); for (int i = 0; i < tempOption.length; i++) { optionsToDisplay[order[i + tempAnswer.length]] = tempOption[i]; } setContentView(R.layout.activity_my); answerButtonsLayout = (LinearLayout) findViewById(R.id.subLinear); if (answerButtonsLayout != null) { answerButtonsLayout.removeAllViews(); } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1); RadioGroup radioGroup = new RadioGroup(this); radioGroup.setOrientation(RadioGroup.VERTICAL); for (int i = 0; i < numberOfButtons; i++) { // build Radio buttons for multiple answers RadioButton box1 = new RadioButton(this); if (i < alphabet.length) { box1.setText(Character.toString(alphabet[i]).concat(")") + optionsToDisplay[i]); } else { box1.setText(Integer.toString(i).concat(") ") + optionsToDisplay[i]); } box1.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (buttonView.isChecked()) { buttonView.setBackgroundColor(Color.GREEN); } else { buttonView.setBackgroundColor(Color.TRANSPARENT); // Color.parseColor() } } }); /** * box1.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ CheckBox * check=(CheckBox) v; if(check.isChecked()){ check.setBackgroundColor(0x0000FF00); }else{ * check.setBackgroundColor(Color.TRANSPARENT); } } * * <p>}); */ radioGroup.addView(box1); box1.setLayoutParams(params); box1.setChecked(intialState[i]); radioButtons[i] = box1; // answerButtonsLayout.addView(box1); } answerButtonsLayout.addView(radioGroup); // Submit button submitRadioButtons = new Button(this); submitRadioButtons.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { radioButtonsAnswer(v); } }); submitRadioButtons.setText("Submit"); submitRadioButtons.setLayoutParams(params); LinearLayout submitButtonLayout = (LinearLayout) findViewById(R.id.submit); if (submitButtonLayout != null) { submitButtonLayout.removeAllViews(); } submitButtonLayout.addView(submitRadioButtons); TextView questionView = (TextView) findViewById(R.id.textView); questionView.setMovementMethod(new ScrollingMovementMethod()); questionView.setText(question.getQuestion()); }
public void init() { btnMenu = (Button) getView().findViewById(R.id.menu_button_settings); btnMenu.setOnClickListener(buildMenuButtonListener()); tvFragmentName = (TextView) getView().findViewById(R.id.fragment_name_settings); tvColor = (TextView) getView().findViewById(R.id.tv_color_settings); tvContactSNS = (TextView) getView().findViewById(R.id.tv_contact_sns_settings); tvFacebook = (TextView) getView().findViewById(R.id.tv_facebook_settings); tvTwitter = (TextView) getView().findViewById(R.id.tv_twitter_settings); tvInstagram = (TextView) getView().findViewById(R.id.tv_instagram_settings); tvAppName = (TextView) getView().findViewById(R.id.app_name_settings); llFacebookLayout = (LinearLayout) getView().findViewById(R.id.ll_facebook_settings); llTwitterLayout = (LinearLayout) getView().findViewById(R.id.ll_twitter_settings); llInstagramLayout = (LinearLayout) getView().findViewById(R.id.ll_instagram_settings); lyTopBar = (LinearLayout) getView().findViewById(R.id.top_bar_settings); radioPink = (RadioButton) getView().findViewById(R.id.radio_pink_settings); radioGreen = (RadioButton) getView().findViewById(R.id.radio_green_settings); radioGray = (RadioButton) getView().findViewById(R.id.radio_gray_settings); vColorBar = (View) getView().findViewById(R.id.color_bar_settings); vContactSnsBar = (View) getView().findViewById(R.id.contact_sns_bar_settings); tvFragmentName.setTypeface(ResourceManager.getInstance().getFont("helvetica")); tvColor.setTypeface(ResourceManager.getInstance().getFont("helvetica")); tvContactSNS.setTypeface(ResourceManager.getInstance().getFont("helvetica")); tvFacebook.setTypeface(ResourceManager.getInstance().getFont("helvetica")); tvTwitter.setTypeface(ResourceManager.getInstance().getFont("helvetica")); tvInstagram.setTypeface(ResourceManager.getInstance().getFont("helvetica")); tvAppName.setTypeface(ResourceManager.getInstance().getFont("helvetica")); llFacebookLayout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { FacebookManager.getInstance().onClickFacebook(); } }); llTwitterLayout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { TwitterManager.getInstance().connect(); } }); llInstagramLayout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } }); radioPink.setOnCheckedChangeListener(buildRadioButtonCheckedListener()); radioGreen.setOnCheckedChangeListener(buildRadioButtonCheckedListener()); radioGray.setOnCheckedChangeListener(buildRadioButtonCheckedListener()); }
/** 第一次启动投注提示框 */ public void initTouZhuDialog() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.alert_dialog_touzhu_new, null); touZhuDialog = new Dialog(this, R.style.MyDialog); initImageView(v); if (betAndGift.isZhui()) { initZhuiJia(v); } issueText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_textview_qihao); alertText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_one); textZhuma = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma); textTitle = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma_title); addView.getCodeList().get(addView.getSize() - 1).setTextCodeColor(textZhuma, null, null); issueText.setText(PublicMethod.toIssue(betAndGift.getLotno()) + "期"); alertText.setText(getTouzhuAlert()); textTitle.setText("注码:" + "共有" + addView.getSize() + "笔投注"); Button cancel = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_cancel); Button ok = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_ok); codeInfo = (Button) v.findViewById(R.id.alert_dialog_touzhu_btn_look_code); isCodeText(codeInfo); codeInfo.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub addView.createCodeInfoDialog(); addView.showDialog(); } }); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub toLogin = false; touZhuDialog.cancel(); clearProgress(); } }); ok.setOnClickListener( new OnClickListener() { public void onClick(View v) { RWSharedPreferences pre = new RWSharedPreferences(ZixuanActivity.this, "addInfo"); sessionId = pre.getStringValue("sessionid"); phonenum = pre.getStringValue("phonenum"); userno = pre.getStringValue("userno"); if (userno.equals("")) { toLogin = true; Intent intentSession = new Intent(ZixuanActivity.this, UserLogin.class); startActivityForResult(intentSession, 0); } else { touZhu(); } } }); CheckBox checkPrize = (CheckBox) v.findViewById(R.id.alert_dialog_touzhu_check_prize); checkPrize.setChecked(true); // 设置betAndGift.prizeend与checkPrize保持一致 betAndGift.setPrizeend("1"); checkPrize.setButtonDrawable(R.drawable.check_on_off); checkPrize.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) { betAndGift.setPrizeend("1"); } else { betAndGift.setPrizeend("0"); } } }); check = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu_check); joinCheck = (RadioButton) v.findViewById(R.id.alert_dialog_join_check); touzhuCheck = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu1_check); touzhuCheck.setChecked(true); textAlert = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_alert); check.setPadding(50, 0, 0, 0); check.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 check.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isGift = isChecked; } }); joinCheck.setPadding(50, 0, 0, 0); joinCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 joinCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isJoin = isChecked; } }); touzhuCheck.setPadding(50, 0, 0, 0); touzhuCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 touzhuCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isTouzhu = isChecked; } }); stateCheck(); touZhuDialog.setCancelable(false); touZhuDialog.setContentView(v); touZhuDialog.show(); }
/** * 此方法别删除,现在搞不大清楚transfer entry里的account是从哪来的 * * @param accountsForServiceModels * @param selectedAccountsModel */ public void createAccountsUI( final List<AccountsForServiceModel> accountsForServiceModels, final AccountsModel selectedAccountsModel) { this.selectedAccountsModel = selectedAccountsModel; boolean accountbyservicemode = false; if (BaseActivity.isOffline) { return; } if (this.accountsForServiceModels == accountsForServiceModels) { } else { this.accountsForServiceModels = accountsForServiceModels; } for (int index = 0; index < tranGroup.getChildCount(); index++) { RadioButton child = (RadioButton) tranGroup.getChildAt(index); child.setOnCheckedChangeListener(null); } tranGroup.removeAllViews(); if (accountbyservicemode) { for (int i = 0; i < accountsForServiceModels.size(); i++) { AccountsForServiceModel accountsForServiceModel = accountsForServiceModels.get(i); LogManager.d(accountsForServiceModel.getServiceCode()); for (AccountsModel accountsModel : accountsForServiceModel.getAccounts()) { // LogManager.d(accountsModel.getAccountAlias()); LayoutInflater layoutInflater = LayoutInflater.from(getContext()); RadioButton radioButton = (RadioButton) layoutInflater.inflate(R.layout.bank_radio_button_item, null); radioButton.setText(accountsModel.getAccountAlias()); if (accountsModel == selectedAccountsModel) { radioButton.setEnabled(false); } radioButton.setTag(accountsModel); radioButton.setOnCheckedChangeListener(PayeeExpandedLayout.this); tranGroup.addView(radioButton); } } } else { LogManager.d("owner is get"); PaymentConfirmLayout paymentConfirmLayout = (PaymentConfirmLayout) expandBarResultListener.getOwener(); List<Account> bankRecipients = paymentConfirmLayout.getRecipientListModel.getBankRecipientList(); if (bankRecipients != null) { for (AccountsForServiceModel bankRecipient : accountsForServiceModels) { List<AccountsModel> accounts = bankRecipient.getAccounts(); for (AccountsModel account : accounts) { LayoutInflater layoutInflater = LayoutInflater.from(getContext()); RadioButton radioButton = (RadioButton) layoutInflater.inflate(R.layout.bank_radio_button_item, null); radioButton.setText(account.getAccountAlias()); if (selectedAccountsModel.getAccountAlias() == account.getAccountAlias()) { radioButton.setEnabled(false); } radioButton.setTag(account); radioButton.setOnCheckedChangeListener(PayeeExpandedLayout.this); tranGroup.addView(radioButton); } } } } if (currentTypeCode.equals(ServiceCode.TRANSFER_ENTRY_PAYMENT)) { expandFocusResultChange(""); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); k = 0; setContentView(R.layout.activity_main); progressBar = (ProgressBar) findViewById(R.id.progresbar); progressBar.setVisibility(View.VISIBLE); // ----------------------------------------- // nothing!! ObservableScrollView scrollview = (ObservableScrollView) findViewById(R.id.scrollview); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.next); fab.attachToScrollView(scrollview); ll = (LinearLayout) findViewById(R.id.ll2); quizname = getIntent().getStringExtra("quizname"); url = getIntent().getStringExtra("URI"); totalq = getIntent().getStringExtra("totalq"); // ------------------------------------------ toolbar = (Toolbar) findViewById(R.id.app_bar); toolbar.setTitleTextColor(getResources().getColor(R.color.white)); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.teal))); actionBar.setTitle("ORGANIC CHEMISTRY "); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_back_white)); toolbar.setNavigationOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); // PB in Gap-by default given//do something } }); // -------------------------------------------- /* ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.actionbar_background)));*/ // ------------------------------------------------------------- imageLoader = AppController.getInstance().getImageLoader(); timer = (TextView) findViewById(R.id.timer); cor = (TextView) findViewById(R.id.tcorrect); inc = (TextView) findViewById(R.id.incorrect); tot = (TextView) findViewById(R.id.tot); Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/pie.ttf"); /* cor.setTypeface(myTypeface); inc.setTypeface(myTypeface); tot.setTypeface(myTypeface);*/ t1 = (RadioButton) findViewById(R.id.t1); t2 = (RadioButton) findViewById(R.id.t2); t3 = (RadioButton) findViewById(R.id.t3); t4 = (RadioButton) findViewById(R.id.t4); question = (TextView) findViewById(R.id.question); v1 = (ImageView) findViewById(R.id.v1); v2 = (ImageView) findViewById(R.id.v2); v3 = (ImageView) findViewById(R.id.v3); v4 = (ImageView) findViewById(R.id.v4); questionimage = (ImageView) findViewById(R.id.questionimage); questionimage2 = (ImageView) findViewById(R.id.questionimage2); questionimage3 = (ImageView) findViewById(R.id.questionimage3); questionimage4 = (ImageView) findViewById(R.id.questionimage4); qiarr = new ImageView[] {questionimage, questionimage2, questionimage3, questionimage4}; next = (FloatingActionButton) findViewById(R.id.next); next.setOnClickListener(this); t1.setOnCheckedChangeListener(this); t2.setOnCheckedChangeListener(this); t3.setOnCheckedChangeListener(this); t4.setOnCheckedChangeListener(this); AlertDialog.Builder builder1; // AlertDialog.Builder builder; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder1 = new AlertDialog.Builder( this, android.R.style.Theme_Material_Light_Dialog_Alert); // theme problem } else { builder1 = new AlertDialog.Builder(this); } builder1.setTitle("Test Information"); builder1.setMessage( "This test would have " + totalq + " questions and you would get 1 minute for each question. All the best! ;)"); builder1.setCancelable(true); // change builder1.setNeutralButton( android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); getdata(); } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { builder1.setOnDismissListener( new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { getdata(); Log.d("ondismiss", "dismissed"); } }); } AlertDialog alert11 = builder1.create(); alert11.show(); }
/** 第一次启动投注提示框 */ public void initTouZhuDialog() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.alert_dialog_touzhu_new, null); touZhuDialog = new AlertDialog.Builder(this).setTitle("您选择的是").create(); touZhuDialog.show(); initImageView(v); if (betAndGift.isZhui()) { initZhuiJia(v); } issueText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_textview_qihao); alertText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_one); textZhuma = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma); addView.getCodeList().get(addView.getSize() - 1).setTextCodeColor(textZhuma); textTitle = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma_title); textTitle.setText("注码:" + "共有" + addView.getSize() + "笔投注"); issueText.setText(PublicMethod.toIssue(betAndGift.getLotno()) + "期"); alertText.setText(getTouzhuAlertJixuan()); Button cancel = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_cancel); Button ok = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_ok); codeInfo = (Button) v.findViewById(R.id.alert_dialog_touzhu_btn_look_code); isCodeText(codeInfo); codeInfo.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub addView.createCodeInfoDialog(); addView.showDialog(); } }); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub touZhuDialog.cancel(); toLogin = false; clearProgress(); } }); ok.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { toLogin = false; initBet(); touZhuDialog.cancel(); // TODO Auto-generated method stub if (isGift) { String code = addView.getsharezhuma(); toActivity(code); } else if (isJoin) { toJoinActivity(); } else if (isTouzhu) { touZhuNet(); } clearProgress(); } }); CheckBox checkPrize = (CheckBox) v.findViewById(R.id.alert_dialog_touzhu_check_prize); checkPrize.setChecked(true); checkPrize.setButtonDrawable(R.drawable.check_on_off); checkPrize.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) { betAndGift.setPrizeend("1"); } else { betAndGift.setPrizeend("0"); } } }); check = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu_check); joinCheck = (RadioButton) v.findViewById(R.id.alert_dialog_join_check); touzhuCheck = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu1_check); touzhuCheck.setChecked(true); textAlert = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_alert); check.setPadding(50, 0, 0, 0); check.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 check.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isGift = isChecked; } }); joinCheck.setPadding(50, 0, 0, 0); joinCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 joinCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isJoin = isChecked; } }); touzhuCheck.setPadding(50, 0, 0, 0); touzhuCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 touzhuCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isTouzhu = isChecked; } }); stateCheck(); touZhuDialog.setCancelable(false); touZhuDialog.getWindow().setContentView(v); }
/** 初始化. */ private void inits() { context = this; view = View.inflate(this, R.layout.activity_main, null); // 初始化ActionBar的样式 initActionbarByFragment(View.GONE); // END. // 初始化底部的RadioButton. rbtnSee = (RadioButton) findViewById(R.id.rbtn_see); rbtnSimg = (RadioButton) findViewById(R.id.rbtn_simg); rbtnAbout = (RadioButton) findViewById(R.id.rbtn_about); rbtnSee.setOnCheckedChangeListener(this); rbtnSimg.setOnCheckedChangeListener(this); rbtnAbout.setOnCheckedChangeListener(this); // END. fragment_container = (FrameLayout) findViewById(R.id.fragment_container); // 底部弹出框. imagePopupWindow = new PopupWindowUtils( this, R.layout.simg_bottom_dialog, R.id.simg_bottom_pop_layout, new int[] { R.id.btn_simg_setdesktop, R.id.btn_simg_saveimg, R.id.btn_wxshare_friend, R.id.btn_wxshare_moments, R.id.btn_wxshare_collent, R.id.btn_yixinshare_timeline, R.id.btn_yixinshare_friend, R.id.btn_yixinshare_collect, R.id.btn_qqshare, R.id.btn_qzoneshare }, this); // 底部弹出框END. R.id.btn_sinaweiboshare,eSe if (dialog == null) { dialog = new CustomProgressDialog(this, "正在加载中"); } // 将应用注册到微信. // TODO 配置微信分享APPID /*wxapi = WXAPIFactory.createWXAPI(this, WxUtils.WXAPPID, true); wxapi.registerApp(WxUtils.WXAPPID); wxutils = WxUtils.getInstence(wxapi, context);*/ // END. // 易信. /* * TODO 配置易信APPID * yxapi = YXAPIFactory.createYXAPI(this, YxUtils.YX_APPID); yxapi.registerApp(); yxutils = YxUtils.getInstance(yxapi, context); */ // END. /*//新浪微博.TODO 配置新浪微博APPID sinaweiboapi = WeiboShareSDK.createWeiboAPI(this, SinaWeiboConstants.APP_KEY); sinaweiboapi.registerApp();*/ // END. // TODO 配置QQ APPID /*tencent = Tencent.createInstance("", this.getApplicationContext()); qqShareUtils = QQShareUtils.getInstance(this, tencent, MainActivity.this); UmengUpdateAgent.update(this);//友盟自动更新 UmengUpdateAgent.setUpdateCheckConfig(false);*/ initSee(); }
/** 监听器 */ private void listen() { rb_shouye.setOnCheckedChangeListener(checkListener); rb_jiaoyiguanli.setOnCheckedChangeListener(checkListener); rb_caiwushi.setOnCheckedChangeListener(checkListener); rb_mine.setOnCheckedChangeListener(checkListener); }
protected ItemsetWidget( Context context, FormEntryPrompt prompt, boolean readOnlyOverride, boolean derived) { super(context, prompt); mButtons = new RadioGroup(context); mButtons.setId(QuestionWidget.newUniqueId()); mReadOnly = prompt.isReadOnly() || readOnlyOverride; mAnswers = new HashMap<String, String>(); String currentAnswer = prompt.getAnswerText(); // the format of the query should be something like this: // query="instance('cities')/root/item[state=/data/state and county=/data/county]" // "query" is what we're using to notify that this is an // itemset widget. String nodesetStr = prompt.getQuestion().getAdditionalAttribute(null, "query"); // parse out the list name, between the '' String list_name = nodesetStr.substring(nodesetStr.indexOf("'") + 1, nodesetStr.lastIndexOf("'")); // isolate the string between between the [ ] characters String queryString = nodesetStr.substring(nodesetStr.indexOf("[") + 1, nodesetStr.lastIndexOf("]")); StringBuilder selection = new StringBuilder(); // add the list name as the first argument, which will always be there selection.append("list_name=?"); // check to see if there are any arguments if (queryString.indexOf("=") != -1) { selection.append(" and "); } // can't just split on 'and' or 'or' because they have different // behavior, so loop through and break them off until we don't have any // more // must include the spaces in indexOf so we don't match words like // "land" int andIndex = -1; int orIndex = -1; ArrayList<String> arguments = new ArrayList<String>(); while ((andIndex = queryString.indexOf(" and ")) != -1 || (orIndex = queryString.indexOf(" or ")) != -1) { if (andIndex != -1) { String subString = queryString.substring(0, andIndex); String pair[] = subString.split("="); if (pair.length == 2) { selection.append(pair[0].trim() + "=? and "); arguments.add(pair[1].trim()); } else { // parse error } // move string forward to after " and " queryString = queryString.substring(andIndex + 5, queryString.length()); andIndex = -1; } else if (orIndex != -1) { String subString = queryString.substring(0, orIndex); String pair[] = subString.split("="); if (pair.length == 2) { selection.append(pair[0].trim() + "=? or "); arguments.add(pair[1].trim()); } else { // parse error } // move string forward to after " or " queryString = queryString.substring(orIndex + 4, queryString.length()); orIndex = -1; } } // parse the last segment (or only segment if there are no 'and' or 'or' // clauses String pair[] = queryString.split("="); if (pair.length == 2) { selection.append(pair[0].trim() + "=?"); arguments.add(pair[1].trim()); } if (pair.length == 1) { // this is probably okay, because then you just list all items in // the list } else { // parse error } // +1 is for the list_name String[] selectionArgs = new String[arguments.size() + 1]; boolean nullArgs = false; // can't have any null arguments selectionArgs[0] = list_name; // first argument is always listname // loop through the arguments, evaluate any expressions // and build the query string for the DB for (int i = 0; i < arguments.size(); i++) { XPathExpression xpr = null; try { xpr = XPathParseTool.parseXPath(arguments.get(i)); } catch (XPathSyntaxException e) { e.printStackTrace(); TextView error = new TextView(context); error.setText("XPathParser Exception: \"" + arguments.get(i) + "\""); addView(error); break; } if (xpr != null) { FormDef form = Collect.getInstance().getFormController().getFormDef(); TreeElement mTreeElement = form.getMainInstance().resolveReference(prompt.getIndex().getReference()); EvaluationContext ec = new EvaluationContext(form.getEvaluationContext(), mTreeElement.getRef()); Object value = xpr.eval(form.getMainInstance(), ec); if (value == null) { nullArgs = true; } else { if (value instanceof XPathNodeset) { XPathNodeset xpn = (XPathNodeset) value; value = xpn.getValAt(0); } selectionArgs[i + 1] = value.toString(); } } } File itemsetFile = new File( Collect.getInstance().getFormController().getMediaFolder().getAbsolutePath() + "/itemsets.csv"); if (nullArgs) { // we can't try to query with null values else it blows up // so just leave the screen blank // TODO: put an error? } else if (itemsetFile.exists()) { ItemsetDbAdapter ida = new ItemsetDbAdapter(); ida.open(); // name of the itemset table for this form String pathHash = ItemsetDbAdapter.getMd5FromString(itemsetFile.getAbsolutePath()); try { Cursor c = ida.query(pathHash, selection.toString(), selectionArgs); if (c != null) { c.move(-1); while (c.moveToNext()) { String label = ""; String val = ""; // try to get the value associated with the label:lang // string if that doen't exist, then just use label String lang = ""; if (Collect.getInstance().getFormController().getLanguages() != null && Collect.getInstance().getFormController().getLanguages().length > 0) { lang = Collect.getInstance().getFormController().getLanguage(); } // apparently you only need the double quotes in the // column name when creating the column with a : // included String labelLang = "label" + "::" + lang; int langCol = c.getColumnIndex(labelLang); if (langCol == -1) { label = c.getString(c.getColumnIndex("label")); } else { label = c.getString(c.getColumnIndex(labelLang)); } // the actual value is stored in name val = c.getString(c.getColumnIndex("name")); mAnswers.put(label, val); RadioButton rb = new RadioButton(context); rb.setOnCheckedChangeListener(this); rb.setText(label); rb.setTextSize(mAnswerFontsize); mButtons.addView(rb); // have to add it to the radiogroup before checking it, // else it lets two buttons be checked... if (currentAnswer != null && val.compareTo(currentAnswer) == 0) { rb.setChecked(true); } } c.close(); } } finally { ida.close(); } addView(mButtons); } else { TextView error = new TextView(context); error.setText(getContext().getString(R.string.file_missing, itemsetFile.getAbsolutePath())); addView(error); } }
private void initializeComponent() { btnOK = (Button) view.findViewById(R.id.btnOK); btnOK.setOnClickListener(this); edtBirthday = (EditText) view.findViewById(R.id.edtBirthday); edtBirthday.setOnClickListener(this); edtFirstName = (EditText) view.findViewById(R.id.edtFirstName); edtLastName = (EditText) view.findViewById(R.id.edtLastName); edtEmail = (EditText) view.findViewById(R.id.edtEmail); edtFirstName.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s != null && s.length() > 1) { isFillFirstName = true; ProfileInformationFragment.this.enabledButtonOK(); } else { isFillFirstName = false; btnOK.setEnabled(false); } } @Override public void afterTextChanged(Editable s) {} }); edtLastName.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s != null && s.length() > 1) { isFillLastName = true; ProfileInformationFragment.this.enabledButtonOK(); } else { isFillLastName = false; btnOK.setEnabled(false); } } @Override public void afterTextChanged(Editable s) {} }); edtEmail.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s != null && s.length() > 1) { isFillEmail = true; ProfileInformationFragment.this.enabledButtonOK(); } else { isFillEmail = false; btnOK.setEnabled(false); } } @Override public void afterTextChanged(Editable s) { if (!validate(s.toString())) { edtEmail.setError("Email is not valid"); } else { edtEmail.setError(null); } } }); radioMale = (RadioButton) view.findViewById(R.id.radioMale); radioFemale = (RadioButton) view.findViewById(R.id.radioFemale); radioMale.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { gender = true; radioMale.setTextColor(Color.parseColor("#4caf50")); } else { gender = false; radioMale.setTextColor(Color.parseColor("#666666")); } } }); radioFemale.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { gender = false; radioFemale.setTextColor(Color.parseColor("#4caf50")); } else { gender = true; radioFemale.setTextColor(Color.parseColor("#666666")); } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_connection); // Hide the keyboard by default this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); this.startButton = (Button) findViewById(R.id.startButton); this.pairButton = (Button) findViewById(R.id.pairButton); this.hostText = (TextView) findViewById(R.id.hostTextView); this.rbutton720p30 = (RadioButton) findViewById(R.id.config720p30Selected); this.rbutton720p60 = (RadioButton) findViewById(R.id.config720p60Selected); this.rbutton1080p30 = (RadioButton) findViewById(R.id.config1080p30Selected); this.rbutton1080p60 = (RadioButton) findViewById(R.id.config1080p60Selected); this.forceSoftDec = (RadioButton) findViewById(R.id.softwareDec); this.autoDec = (RadioButton) findViewById(R.id.autoDec); this.forceHardDec = (RadioButton) findViewById(R.id.hardwareDec); this.bitrateLabel = (TextView) findViewById(R.id.bitrateLabel); this.bitrateSlider = (SeekBar) findViewById(R.id.bitrateSeekBar); this.appsListView = (ListView) findViewById(R.id.gamesListView); this.currentAppLabel = (TextView) findViewById(R.id.currentAppLabel); prefs = getSharedPreferences(Game.PREFS_FILE_NAME, Context.MODE_MULTI_PROCESS); this.hostText.setText(prefs.getString(Connection.HOST_KEY, Connection.DEFAULT_HOST)); boolean res720p = prefs.getInt(Game.HEIGHT_PREF_STRING, Game.DEFAULT_HEIGHT) == 720; boolean fps30 = prefs.getInt(Game.REFRESH_RATE_PREF_STRING, Game.DEFAULT_REFRESH_RATE) == 30; bitrateSlider.setMax(Game.BITRATE_CEILING); bitrateSlider.setProgress(prefs.getInt(Game.BITRATE_PREF_STRING, Game.DEFAULT_BITRATE)); updateBitrateLabel(); rbutton720p30.setChecked(false); rbutton720p60.setChecked(false); rbutton1080p30.setChecked(false); rbutton1080p60.setChecked(false); if (res720p) { if (fps30) { rbutton720p30.setChecked(true); } else { rbutton720p60.setChecked(true); } } else { if (fps30) { rbutton1080p30.setChecked(true); } else { rbutton1080p60.setChecked(true); } } switch (prefs.getInt(Game.DECODER_PREF_STRING, Game.DEFAULT_DECODER)) { case Game.FORCE_SOFTWARE_DECODER: forceSoftDec.setChecked(true); autoDec.setChecked(false); forceHardDec.setChecked(false); break; case Game.AUTOSELECT_DECODER: forceSoftDec.setChecked(false); autoDec.setChecked(true); forceHardDec.setChecked(false); break; case Game.FORCE_HARDWARE_DECODER: forceSoftDec.setChecked(false); autoDec.setChecked(false); forceHardDec.setChecked(true); break; } // loading the apps from preferences supportedApps = new ArrayList<String>(prefs.getStringSet(Game.APP_LIST, Game.DEFAULT_APP_LIST)); Collections.sort(supportedApps); if (supportedApps.isEmpty()) { appsListView.setVisibility(View.GONE); } updateCurrentAppLabel(); appsArrayAdapter = new ArrayAdapter<String>(this, R.layout.app_layout, supportedApps); appsListView.setAdapter(appsArrayAdapter); // taken from http://stackoverflow.com/questions/18367522/android-list-view-inside-a-scroll-view appsListView.setOnTouchListener( new OnTouchListener() { // Setting on Touch Listener for handling the touch inside ScrollView @Override public boolean onTouch(View v, MotionEvent event) { // Disallow the touch request for parent scroll on touch of child view v.getParent().requestDisallowInterceptTouchEvent(true); return false; } }); appsListView.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { prefs.edit().putString(Game.SELECTED_APP, appsArrayAdapter.getItem(position)).commit(); updateCurrentAppLabel(); } }); OnCheckedChangeListener occl = new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { // Ignore non-checked buttons return; } if (buttonView == rbutton720p30) { prefs .edit() .putInt(Game.WIDTH_PREF_STRING, 1280) .putInt(Game.HEIGHT_PREF_STRING, 720) .putInt(Game.REFRESH_RATE_PREF_STRING, 30) .putInt(Game.BITRATE_PREF_STRING, Game.BITRATE_DEFAULT_720_30) .commit(); bitrateSlider.setProgress(Game.BITRATE_DEFAULT_720_30); } else if (buttonView == rbutton720p60) { prefs .edit() .putInt(Game.WIDTH_PREF_STRING, 1280) .putInt(Game.HEIGHT_PREF_STRING, 720) .putInt(Game.REFRESH_RATE_PREF_STRING, 60) .putInt(Game.BITRATE_PREF_STRING, Game.BITRATE_DEFAULT_720_60) .commit(); bitrateSlider.setProgress(Game.BITRATE_DEFAULT_720_60); } else if (buttonView == rbutton1080p30) { prefs .edit() .putInt(Game.WIDTH_PREF_STRING, 1920) .putInt(Game.HEIGHT_PREF_STRING, 1080) .putInt(Game.REFRESH_RATE_PREF_STRING, 30) .putInt(Game.BITRATE_PREF_STRING, Game.BITRATE_DEFAULT_1080_30) .commit(); bitrateSlider.setProgress(Game.BITRATE_DEFAULT_1080_30); } else if (buttonView == rbutton1080p60) { prefs .edit() .putInt(Game.WIDTH_PREF_STRING, 1920) .putInt(Game.HEIGHT_PREF_STRING, 1080) .putInt(Game.REFRESH_RATE_PREF_STRING, 60) .putInt(Game.BITRATE_PREF_STRING, Game.BITRATE_DEFAULT_1080_60) .commit(); bitrateSlider.setProgress(Game.BITRATE_DEFAULT_1080_60); } else if (buttonView == forceSoftDec) { prefs.edit().putInt(Game.DECODER_PREF_STRING, Game.FORCE_SOFTWARE_DECODER).commit(); } else if (buttonView == forceHardDec) { prefs.edit().putInt(Game.DECODER_PREF_STRING, Game.FORCE_HARDWARE_DECODER).commit(); } else if (buttonView == autoDec) { prefs.edit().putInt(Game.DECODER_PREF_STRING, Game.AUTOSELECT_DECODER).commit(); } } }; rbutton720p30.setOnCheckedChangeListener(occl); rbutton720p60.setOnCheckedChangeListener(occl); rbutton1080p30.setOnCheckedChangeListener(occl); rbutton1080p60.setOnCheckedChangeListener(occl); forceSoftDec.setOnCheckedChangeListener(occl); forceHardDec.setOnCheckedChangeListener(occl); autoDec.setOnCheckedChangeListener(occl); this.bitrateSlider.setOnSeekBarChangeListener( new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // Verify the user's selection if (fromUser) { int floor; if (rbutton720p30.isChecked()) { floor = Game.BITRATE_FLOOR_720_30; } else if (rbutton720p60.isChecked()) { floor = Game.BITRATE_FLOOR_720_60; } else if (rbutton1080p30.isChecked()) { floor = Game.BITRATE_FLOOR_1080_30; } else /*if (rbutton1080p60.isChecked())*/ { floor = Game.BITRATE_FLOOR_1080_60; } if (progress < floor) { seekBar.setProgress(floor); return; } } updateBitrateLabel(); } @Override public void onStartTrackingTouch(SeekBar seekBar) {} @Override public void onStopTrackingTouch(SeekBar seekBar) {} }); this.startButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { if (Connection.this.hostText.getText().length() == 0) { Toast.makeText( Connection.this, "Please enter the target PC's IP address in the text box at the top of the screen.", Toast.LENGTH_LONG) .show(); return; } else if (getCurrentApp() == null) { Toast.makeText( Connection.this, "Please choose an app to stream. The app list is showed after pairing with PC.", Toast.LENGTH_LONG) .show(); return; } // Ensure that the bitrate preference is up to date before // starting the game activity prefs.edit().putInt(Game.BITRATE_PREF_STRING, bitrateSlider.getProgress()).commit(); Intent intent = new Intent(Connection.this, Game.class); intent.putExtra("host", Connection.this.hostText.getText().toString()); Connection.this.startActivity(intent); } }); this.pairButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { if (Connection.this.hostText.getText().length() == 0) { Toast.makeText( Connection.this, "Please enter the target PC's IP address in the text box at the top of the screen.", Toast.LENGTH_LONG) .show(); return; } Toast.makeText(Connection.this, "Pairing...", Toast.LENGTH_LONG).show(); new Thread( new Runnable() { @Override public void run() { String macAddress; try { macAddress = NvConnection.getMacAddressString(); } catch (SocketException e) { e.printStackTrace(); return; } if (macAddress == null) { LimeLog.severe("Couldn't find a MAC address"); return; } NvHTTP httpConn; String message; try { httpConn = new NvHTTP( InetAddress.getByName(hostText.getText().toString()), macAddress, PlatformBinding.getDeviceName()); try { if (httpConn.getPairState()) { message = "Already paired"; loadSupportedApps(); } else { int session = httpConn.getSessionId(); if (session == 0) { message = "Pairing was declined by the target"; } else { message = "Pairing was successful"; loadSupportedApps(); } } } catch (IOException e) { message = e.getMessage(); } catch (XmlPullParserException e) { message = e.getMessage(); } } catch (UnknownHostException e1) { message = "Failed to resolve host"; } final String toastMessage = message; runOnUiThread( new Runnable() { @Override public void run() { Toast.makeText(Connection.this, toastMessage, Toast.LENGTH_LONG) .show(); } }); } }) .start(); } }); }