/** Set up spinner navigation with swiped pages */ private void setUpNavigation() { // Navigation spinner in toolbar for trainings selection LayoutInflater.from(mToolbar.getContext()).inflate(R.layout.navigation_spinner, mToolbar, true); mNavigationSpinner = (Spinner) mToolbar.findViewById(R.id.navigation_spinner); mNavigationSpinner.setOnItemSelectedListener(this); mNavigationSpinner.setSelection(mPosition); String[] from = new String[] {Trainings.EXERCISE}; int[] to = new int[] {R.id.title}; mNavigationAdapter = new NavigationAdapter( mToolbar.getContext(), R.layout.navigation_spinner_item, null, from, to, 0); mNavigationAdapter.setDropDownViewResource(R.layout.navigation_spinner_dropdown_item); mNavigationSpinner.setAdapter(mNavigationAdapter); // ViewPager for swipe navigation and animation on training select mViewPager.setOnPageChangeListener(this); mPagerAdapter = new TrainingPagerAdapter(getChildFragmentManager(), null); mViewPager.setAdapter(mPagerAdapter); Loader<Cursor> loader = getLoaderManager().getLoader(0); if (loader != null && !loader.isReset()) { getLoaderManager().restartLoader(0, null, this); } else { getLoaderManager().initLoader(0, null, this); } }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.add_remove_deck_card); Intent intent = getIntent(); mCardId = intent.getLongExtra("CardId", 0); mCardType = (CardType) intent.getSerializableExtra("CardType"); mCardName = DatabaseHelper.getCardName(mCardId, mCardType); // mCardName = "DummyCardName"; mDecks = (Spinner) findViewById(R.id.spinnerDeckName); TextView cardName = (TextView) findViewById(R.id.textCardName); mCardCount = (EditText) findViewById(R.id.editCardNumber); Cursor c = DatabaseHelper.getDecks(); mAdapter = new SimpleCursorAdapter( this, android.R.layout.simple_spinner_item, c, new String[] {"Name"}, new int[] {android.R.id.text1}); mDecks.setAdapter(mAdapter); setLastDeckSpinnerPosition(); mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); cardName.setText(mCardName); mDecks.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub int cardsInDeck = DatabaseHelper.getCountCardsInDeck(id, mCardId, mCardType); mCardCount.setText(String.valueOf(cardsInDeck)); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); mCardCount.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mCardCount.selectAll(); } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { UserID = SyncHelper.createInstance(this).getUserId(); } catch (Exception ex) { Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show(); finish(); } setContentView(R.layout.edit_item_activity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); edName = (EditText) findViewById(R.id.edName); edDesc = (EditText) findViewById(R.id.edDesc); sPriority = (Spinner) findViewById(R.id.sPriority); sStatus = (Spinner) findViewById(R.id.sStatus); tStartDate = (TextView) findViewById(R.id.tStartDate); tStartTime = (TextView) findViewById(R.id.tStartTime); tEndDate = (TextView) findViewById(R.id.tEndDate); tEndTime = (TextView) findViewById(R.id.tEndTime); tStartDate.setOnClickListener(this); tStartTime.setOnClickListener(this); tEndDate.setOnClickListener(this); tEndTime.setOnClickListener(this); adPriority = new SimpleCursorAdapter( this, R.layout.support_simple_spinner_dropdown_item, null, new String[] {Database.Priority.C_NAME}, new int[] {android.R.id.text1}, 0); adPriority.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sPriority.setAdapter(adPriority); adStatus = new SimpleCursorAdapter( this, R.layout.support_simple_spinner_dropdown_item, null, new String[] {Database.Status.NAME}, new int[] {android.R.id.text1}, 0); adStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sStatus.setAdapter(adStatus); Intent intent = getIntent(); if (!Intent.ACTION_INSERT.endsWith(intent.getAction())) { id = intent.getData(); } else { listID = intent.getStringExtra(Item.LISTID); Calendar cal = Calendar.getInstance(); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); tStartDate.setTag(cal); tStartDate.setText(sdfdate.format(cal.getTime())); tStartTime.setTag(cal); tStartTime.setText(sdftime.format(cal.getTime())); cal = Calendar.getInstance(); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cal.add(Calendar.DAY_OF_MONTH, 1); tEndDate.setTag(cal); tEndDate.setText(sdfdate.format(cal.getTime())); tEndTime.setTag(cal); tEndTime.setText(sdftime.format(cal.getTime())); } final DatePickerFragment dateFragment = (DatePickerFragment) getSupportFragmentManager().findFragmentByTag(DatePickerFragmentTag); if (dateFragment != null) { dateFragment.setOnDateSetListener(dpdfListener); } final TimePickerFragment timeFragment = (TimePickerFragment) getSupportFragmentManager().findFragmentByTag(TimePickerFragmentTag); if (timeFragment != null) { timeFragment.setOnTimeSetListener(tpdfListener); } getSupportLoaderManager().initLoader(PriorityLoaderId, null, this); }
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "CreateAccountInstitutionActivity::onCreateView()"); if (container == null) { // We have different layouts, and in one of them this // fragment's containing frame doesn't exist. The fragment // may still be created from its saved state, but there is // no reason to try to create its view hierarchy because it // won't be displayed. Note this is not needed -- we could // just run the code below, where we would create and return // the view hierarchy; it would just never be used. return null; } View view = inflater.inflate(R.layout.createaccount_institution, container, false); // Find our views spinInstitutions = (Spinner) view.findViewById(R.id.accountInstitution); accountNumber = (EditText) view.findViewById(R.id.accountNumber); accountIBAN = (EditText) view.findViewById(R.id.accountIBAN); buttonNewInstitution = (Button) view.findViewById(R.id.buttonNewInstitution); checkboxNoInstitution = (CheckBox) view.findViewById(R.id.checkboxNoInstitution); textInstitutions = (TextView) view.findViewById(R.id.titleAccountInstitution); // Set our listeners for our items. buttonNewInstitution.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { switch (v.getId()) { case R.id.buttonNewInstitution: Intent i = new Intent( getActivity().getBaseContext(), CreateModifyInstitutionActivity.class); i.putExtra("Action", ACTION_NEW); startActivity(i); // Since we are adding a new Institution, make sure we have the spinner displayed. checkboxNoInstitution.setChecked(false); spinInstitutions.setVisibility(0); textInstitutions.setVisibility(0); break; } } }); checkboxNoInstitution.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.checkboxNoInstitution: // if the user is selecting the checkbox, turn off the Institutions spinner if (buttonView.isChecked()) { spinInstitutions.setVisibility(View.GONE); textInstitutions.setVisibility(View.GONE); buttonNewInstitution.setVisibility(View.GONE); } else { spinInstitutions.setVisibility(View.VISIBLE); textInstitutions.setVisibility(View.VISIBLE); buttonNewInstitution.setVisibility(View.VISIBLE); spinInstitutions.setSelection(0); } break; } ((CreateModifyAccountActivity) ParentActivity).setIsDirty(true); } }); spinInstitutions.setOnItemSelectedListener(new AccountInstitutionOnItemSelectedListener()); // Set up the other keyListener's for the various editText items. accountNumber.addTextChangedListener( new TextWatcher() { public void afterTextChanged(Editable s) { ((CreateModifyAccountActivity) ParentActivity).setIsDirty(true); } public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void onTextChanged(CharSequence s, int start, int before, int count) {} }); accountIBAN.addTextChangedListener( new TextWatcher() { public void afterTextChanged(Editable s) { ((CreateModifyAccountActivity) ParentActivity).setIsDirty(true); } public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void onTextChanged(CharSequence s, int start, int before, int count) {} }); // Make sure we start by default with no Institutions showing. checkboxNoInstitution.setChecked(true); // Set up the adapters adapterInst = new SimpleCursorAdapter( getActivity().getBaseContext(), android.R.layout.simple_spinner_item, null, FROM, TO, 0); adapterInst.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); spinInstitutions.setAdapter(adapterInst); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(CAINSTITUTIONS_LOADER, null, this); return view; }