private void initSpinnerGeologyValue(Context context) { slog.p(TAG, "initSpinnerGeologyValue "); ArrayList<String> str = createArrayList(bean.geoObjects); if (adapterGeology != null) { adapterGeology.clear(); adapterGeology.addAll(str); adapterGeology.notifyDataSetChanged(); } else { adapterGeology = new ArrayAdapter<String>(context, getAdapterLayoutID(), str); mSpinnerGeology.setAdapter(adapterGeology); mSpinnerGeology.setSelection(geologyIndex); } }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent == mSpinnerGeology) { geologyIndex = position; new PreferencesUtil(getContext()).save("geologyIndex", geologyIndex); initConditions(getActivity()); initConditions(getActivity()); initConditiontValue(getActivity()); changeAllGeology(); } if (parent == mSpinnerCondition) { conditionIndex = position; initConditions(getActivity()); initConditiontValue(getActivity()); } if (parent == mSpinnerConditionValue) { conditionValueIndex = position; } String selectItem = null; try { selectItem = mSpinnerConditionValue.getSelectedItem().toString(); } catch (Exception e) { e.printStackTrace(); } slog.p(TAG, "selectItem " + selectItem); if (mETValue1 != null && mETValue2 != null) { if (selectItem != null && selectItem.equals("自定义")) { mETValue1.setVisibility(View.VISIBLE); mETValue2.setVisibility(View.VISIBLE); } else { mETValue1.setVisibility(View.GONE); mETValue2.setVisibility(View.GONE); } } }
public String getSpinnerValue(int index) { String value = null; slog.p(TAG, "getFirstSpinnerValue index is " + index); switch (index) { case 0: value = (String) mSpinnerFisrt.getSelectedItem(); break; case 1: value = (String) mSpinnerGeology.getSelectedItem(); break; case 2: value = (String) mSpinnerCondition.getSelectedItem(); break; case 3: value = (String) mSpinnerConditionValue.getSelectedItem(); break; } slog.p(TAG, "getFirstSpinnerValue value is " + value); return value; }
private void initConditions(Context context) { slog.p(TAG, "initConditions geologyIndex " + geologyIndex); ArrayList<String> str = createArrayList(bean.geoObjects.get(geologyIndex).conditions); if (adapterCondition != null) { adapterCondition.clear(); adapterCondition.addAll(str); adapterCondition.notifyDataSetChanged(); } else { adapterCondition = new ArrayAdapter<String>(context, getAdapterLayoutID(), str); mSpinnerCondition.setAdapter(adapterCondition); } }
public QueryItem(Context context) { super(context); LayoutInflater.from(context).inflate(R.layout.layout_condition_query_compotent, this, true); mSpinnerFisrt = (Spinner) findViewById(R.id.id_spner_first); mSpinnerGeology = (Spinner) findViewById(R.id.id_spner_geology); mSpinnerCondition = (Spinner) findViewById(R.id.id_spner_condition); mSpinnerConditionValue = (Spinner) findViewById(R.id.id_spner_condition_value); mETValue1 = (EditText) findViewById(R.id.id_spner_condition_custom_value1); mETValue2 = (EditText) findViewById(R.id.id_spner_condition_custom_value2); geologyIndex = new PreferencesUtil(context).getInt("geologyIndex", 0); initFirstValue(context); initSpinnerGeologyValue(context); initConditions(context); initConditiontValue(context); mSpinnerFisrt.setOnItemSelectedListener(this); mSpinnerGeology.setOnItemSelectedListener(this); mSpinnerCondition.setOnItemSelectedListener(this); mSpinnerConditionValue.setOnItemSelectedListener(this); }
private void initConditiontValue(Context context) { slog.p( TAG, "initConditions geologyIndex " + geologyIndex + " conditionIndex " + conditionIndex); ArrayList<Values> arrsys = bean.geoObjects.get(geologyIndex).conditions.get(conditionIndex).values; // ArrayList<String> str = createArrayList(arrsys); ArrayList<String> str = new ArrayList<String>(); getAllChildStr(arrsys, str); if (adapterConditionValue != null) { adapterConditionValue.clear(); adapterConditionValue.addAll(str); adapterConditionValue.notifyDataSetChanged(); } else { adapterConditionValue = new ArrayAdapter<String>(context, getAdapterLayoutID(), str); mSpinnerConditionValue.setAdapter(adapterConditionValue); } }
public void setSpinerValue(Spinner spinner, int value) { spinner.setSelection(value); }
public void hideFirstSpiner() { mSpinnerFisrt.setVisibility(View.INVISIBLE); }
private void initFirstValue(Context context) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, getAdapterLayoutID(), new String[] {AND /*, "或者"*/}); mSpinnerFisrt.setAdapter(adapter); }