Example usage for android.widget ArrayAdapter setDropDownViewResource

List of usage examples for android.widget ArrayAdapter setDropDownViewResource

Introduction

In this page you can find the example usage for android.widget ArrayAdapter setDropDownViewResource.

Prototype

public void setDropDownViewResource(@LayoutRes int resource) 

Source Link

Document

Sets the layout resource to create the drop down views.

Usage

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflateInterestCalculationPeriodSpinner() {
    showProgress(true);/*from  w w  w  . j a v a  2  s  .  c  o  m*/
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            final List<InterestCalculationPeriodType> interestCalculationPeriodType = new ArrayList<>();
            // you can use this array to populate your spinner
            final ArrayList<String> interestCalculationPeriodTypeNames = new ArrayList<String>();
            //Try to get response body
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                String line;
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("interestCalculationPeriodTypeOptions")) {
                    JSONArray interestCalculationPeriodTypes = obj
                            .getJSONArray("interestCalculationPeriodTypeOptions");
                    for (int i = 0; i < interestCalculationPeriodTypes.length(); i++) {
                        JSONObject interestCalculationPeriodTypeObject = interestCalculationPeriodTypes
                                .getJSONObject(i);
                        InterestCalculationPeriodType interestCalculationPeriod = new InterestCalculationPeriodType();
                        interestCalculationPeriod.setId(interestCalculationPeriodTypeObject.optInt("id"));
                        interestCalculationPeriod
                                .setValue(interestCalculationPeriodTypeObject.optString("value"));
                        interestCalculationPeriodType.add(interestCalculationPeriod);
                        interestCalculationPeriodTypeNames
                                .add(interestCalculationPeriodTypeObject.optString("value"));
                        interestCalculationPeriodTypeIdHashMap.put(interestCalculationPeriod.getValue(),
                                interestCalculationPeriod.getId());
                    }

                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, "", e);
            }
            final ArrayAdapter<String> interestCalculationPeriodTypeAdapter = new ArrayAdapter<>(getActivity(),
                    layout.simple_spinner_item, interestCalculationPeriodTypeNames);
            interestCalculationPeriodTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
            sp_interestcalculationperiod.setAdapter(interestCalculationPeriodTypeAdapter);
            sp_interestcalculationperiod.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    interestCalculationPeriodTypeId = interestCalculationPeriodTypeIdHashMap
                            .get(interestCalculationPeriodTypeNames.get(i));
                    Log.d("interestCalculation " + interestCalculationPeriodTypeNames.get(i),
                            String.valueOf(interestCalculationPeriodTypeId));
                    if (interestCalculationPeriodTypeId != -1) {

                    } else {

                        Toast.makeText(getActivity(),
                                getString(R.string.error_select_interestCalculationPeriod), Toast.LENGTH_SHORT)
                                .show();

                    }

                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflatetransactionProcessingStrategySpinner() {
    showProgress(true);/* ww w. j a va2 s.  com*/
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            final List<TransactionProcessingStrategy> transactionProcessingStrategyType = new ArrayList<>();
            // you can use this array to populate your spinner
            final ArrayList<String> transactionProcessingStrategyTypeNames = new ArrayList<String>();
            //Try to get response body
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                String line;
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("transactionProcessingStrategyOptions")) {
                    JSONArray transactionProcessingStrategyTypes = obj
                            .getJSONArray("transactionProcessingStrategyOptions");
                    for (int i = 0; i < transactionProcessingStrategyTypes.length(); i++) {
                        JSONObject transactionProcessingStrategyTypeObject = transactionProcessingStrategyTypes
                                .getJSONObject(i);
                        TransactionProcessingStrategy transactionProcessingStrategy = new TransactionProcessingStrategy();
                        transactionProcessingStrategy
                                .setId(transactionProcessingStrategyTypeObject.optInt("id"));
                        transactionProcessingStrategy
                                .setName(transactionProcessingStrategyTypeObject.optString("name"));
                        transactionProcessingStrategyType.add(transactionProcessingStrategy);
                        transactionProcessingStrategyTypeNames
                                .add(transactionProcessingStrategyTypeObject.optString("name"));
                        transactionProcessingStrategyTypeIdHashMap.put(transactionProcessingStrategy.getName(),
                                transactionProcessingStrategy.getId());
                    }

                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, "", e);
            }
            final ArrayAdapter<String> transactionProcessingStrategyAdapter = new ArrayAdapter<>(getActivity(),
                    layout.simple_spinner_item, transactionProcessingStrategyTypeNames);
            transactionProcessingStrategyAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
            sp_repaymentstrategy.setAdapter(transactionProcessingStrategyAdapter);
            sp_repaymentstrategy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    transactionProcessingStrategyId = transactionProcessingStrategyTypeIdHashMap
                            .get(transactionProcessingStrategyTypeNames.get(i));
                    Log.d("transactionProcessing " + transactionProcessingStrategyTypeNames.get(i),
                            String.valueOf(transactionProcessingStrategyId));
                    if (transactionProcessingStrategyId != -1) {

                    } else {

                        Toast.makeText(getActivity(),
                                getString(R.string.error_select_transactionProcessingStrategy),
                                Toast.LENGTH_SHORT).show();

                    }

                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.andreadec.musicplayer.MainActivity.java

private void equalizerSettings() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.equalizer);
    View view = getLayoutInflater().inflate(R.layout.layout_equalizer, null);
    builder.setView(view);/*ww  w .  j av a  2 s .c o m*/

    builder.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            updateExtendedMenu();
        }
    });
    builder.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            updateExtendedMenu();
        }
    });

    CheckBox checkBoxEqualizerEnabled = (CheckBox) view.findViewById(R.id.checkBoxEqualizerEnabled);
    checkBoxEqualizerEnabled.setChecked(musicService.getEqualizerEnabled());
    checkBoxEqualizerEnabled.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            musicService.toggleEqualizer();
            updateExtendedMenu();
        }
    });

    String[] availablePresets = musicService.getEqualizerAvailablePresets();
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            availablePresets);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinnerEqualizerPreset = (Spinner) view.findViewById(R.id.spinnerEqualizerPreset);
    spinnerEqualizerPreset.setAdapter(adapter);
    spinnerEqualizerPreset.setSelection(musicService.getEqualizerPreset());

    spinnerEqualizerPreset.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            musicService.setEqualizerPreset(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    builder.show();
}

From source file:com.saulcintero.moveon.fragments.Statistics.java

@SuppressLint("ClickableViewAccessibility")
@Override/*w ww .  ja  va 2  s. c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    fragmentView = (LinearLayout) inflater.inflate(R.layout.statistics, container, false);

    mContext = getActivity().getApplicationContext();

    isRotated = false;

    if (savedInstanceState != null) {
        customDay1 = savedInstanceState.getString("customDay1");
        customDay2 = savedInstanceState.getString("customDay2");
        customMonth1 = savedInstanceState.getString("customMonth1");
        customMonth2 = savedInstanceState.getString("customMonth2");
        customYear1 = savedInstanceState.getString("customYear1");
        customYear2 = savedInstanceState.getString("customYear2");
        show_dialog = savedInstanceState.getInt("show_dialog");
        day1 = savedInstanceState.getInt("day1");
        month1 = savedInstanceState.getInt("month1");
        year1 = savedInstanceState.getInt("year1");
        day2 = savedInstanceState.getInt("day2");
        month2 = savedInstanceState.getInt("month2");
        year2 = savedInstanceState.getInt("year2");
        selected_date = savedInstanceState.getInt("selected_date");
        selected_activity = savedInstanceState.getInt("selected_activity");
        isRotated = savedInstanceState.getBoolean("isRotated");
        spinnerItemSelected = savedInstanceState.getBoolean("spinner1ItemSelected");
    } else {
        removeCustomDataValues();
        restart_dates();
        spinnerItemSelected = true;
    }

    base_layout = (LinearLayout) fragmentView.findViewById(R.id.linearLayout1);
    scrollView = (ScrollView) fragmentView.findViewById(R.id.scrollView1);
    layout1 = (LinearLayout) fragmentView.findViewById(R.id.graph1);
    layout2 = (LinearLayout) fragmentView.findViewById(R.id.graph2);
    layout3 = (LinearLayout) fragmentView.findViewById(R.id.graph3);
    layout4 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout2_B);
    mTableLayout = (TableLayout) fragmentView.findViewById(R.id.dynamictable);
    start_label = (TextView) fragmentView.findViewById(R.id.statistics_start_item);
    spinner1 = (SelectAgainSpinner) fragmentView.findViewById(R.id.spinner1);
    spinner2 = (Spinner) fragmentView.findViewById(R.id.spinner2);
    label1 = (TextView) fragmentView.findViewById(R.id.label_one);
    label2 = (TextView) fragmentView.findViewById(R.id.label_two);
    label3 = (TextView) fragmentView.findViewById(R.id.label_three);
    label4 = (TextView) fragmentView.findViewById(R.id.label_four);
    label5 = (TextView) fragmentView.findViewById(R.id.label_five);
    label6 = (TextView) fragmentView.findViewById(R.id.label_six);
    label7 = (TextView) fragmentView.findViewById(R.id.label_seven);
    label8 = (TextView) fragmentView.findViewById(R.id.label_eight);
    label9 = (TextView) fragmentView.findViewById(R.id.label_nine);
    label10 = (TextView) fragmentView.findViewById(R.id.label_ten);
    label11 = (TextView) fragmentView.findViewById(R.id.label_eleven);
    label12 = (TextView) fragmentView.findViewById(R.id.label_twelve);
    label13 = (TextView) fragmentView.findViewById(R.id.label_thirteen);
    label14 = (TextView) fragmentView.findViewById(R.id.label_fourteen);
    text1 = (TextView) fragmentView.findViewById(R.id.text_one);
    text2 = (TextView) fragmentView.findViewById(R.id.text_two);
    text3 = (TextView) fragmentView.findViewById(R.id.text_three);
    text4 = (TextView) fragmentView.findViewById(R.id.text_four);
    text5 = (TextView) fragmentView.findViewById(R.id.text_five);
    text6 = (TextView) fragmentView.findViewById(R.id.text_six);
    text7 = (TextView) fragmentView.findViewById(R.id.text_seven);
    text8 = (TextView) fragmentView.findViewById(R.id.text_eight);
    text9 = (TextView) fragmentView.findViewById(R.id.text_nine);
    text10 = (TextView) fragmentView.findViewById(R.id.text_ten);
    text11 = (TextView) fragmentView.findViewById(R.id.text_eleven);
    text12 = (TextView) fragmentView.findViewById(R.id.text_twelve);
    text13 = (TextView) fragmentView.findViewById(R.id.text_thirteen);
    text14 = (TextView) fragmentView.findViewById(R.id.text_fourteen);

    label1.setText(getString(R.string.statistics_label1).toUpperCase(Locale.getDefault()));
    label2.setText(getString(R.string.statistics_label2).toUpperCase(Locale.getDefault()));
    label3.setText(getString(R.string.statistics_label3).toUpperCase(Locale.getDefault()));
    label4.setText(getString(R.string.statistics_label4).toUpperCase(Locale.getDefault()));
    label5.setText(getString(R.string.statistics_label5).toUpperCase(Locale.getDefault()));
    label6.setText(getString(R.string.statistics_label6).toUpperCase(Locale.getDefault()));
    label7.setText(getString(R.string.statistics_label7).toUpperCase(Locale.getDefault()));
    label8.setText(getString(R.string.statistics_label8).toUpperCase(Locale.getDefault()));
    label9.setText(getString(R.string.statistics_label9).toUpperCase(Locale.getDefault()));
    label10.setText(getString(R.string.statistics_label10).toUpperCase(Locale.getDefault()));
    label11.setText(getString(R.string.statistics_label11).toUpperCase(Locale.getDefault()));
    label12.setText(getString(R.string.statistics_label12).toUpperCase(Locale.getDefault()));
    label13.setText(getString(R.string.statistics_label13).toUpperCase(Locale.getDefault()));
    label14.setText(getString(R.string.statistics_label14).toUpperCase(Locale.getDefault()));

    res = mContext.getResources();
    activities = res.getStringArray(R.array.activities);

    String[] choiceTimeList = res.getStringArray(R.array.choice_time_list);
    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item, choiceTimeList);
    spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(spinnerArrayAdapter);

    String[] choiceActivityList = new String[activities.length + 1];
    choiceActivityList[0] = getString(R.string.activitylist_header_two);
    for (int d = 0; d < activities.length; d++) {
        choiceActivityList[d + 1] = activities[d];
    }

    ArrayAdapter<String> spinnerArrayAdapter2 = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item, choiceActivityList);
    spinnerArrayAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner2.setAdapter(spinnerArrayAdapter2);

    spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if ((selected_date != position && position < 4) || (position == 4 && spinnerItemSelected)) {
                selected_date = position;
                paintData();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    spinner1.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN)
                spinnerItemSelected = true;

            return false;
        }
    });

    spinner2.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
            if (selected_activity != position) {
                selected_activity = position;
                paintData();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

    spinner2.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN)
                spinnerItemSelected = true;

            return false;
        }
    });

    paintData();

    intentFilter = new IntentFilter("android.intent.action.REFRESH_STATISTICS");
    getActivity().registerReceiver(mReceiverRefreshStatistics, intentFilter);

    return fragmentView;
}

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

private ActionBarDrawerToggle initializeDrawerToggle() {
    final int drawerImageRes;

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    //actionBar.setCustomView(mTextView);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayShowCustomEnabled(false);
    actionBar.setIcon(R.drawable.icon);//from w  ww.  jav  a  2  s.  co m
    actionBar.setTitle("");//ZV

    //actionBar.setBackgroundDrawable(new ColorDrawable(Color.rgb(197, 197, 197))); //ZV

    final ArrayAdapter<CharSequence> actionBarAdapter = new ArrayAdapter<>(actionBar.getThemedContext(),
            android.R.layout.simple_spinner_item);
    for (final String tab : TAB_LIST) {
        actionBarAdapter.add(getText(LibraryTabsUtil.getTabTitleResId(tab)));
    }

    actionBarAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    actionBar.setListNavigationCallbacks(actionBarAdapter, this);

    /**
     * @param Activity activity
     * @param DrawerLayout
     * @param drawerImageRes nav drawer icon to replace 'Up' caret
     * @param openDrawerContentDescRes "open drawer" description
     * @param closeDrawerContentDescRes "close drawer" description
     */
    return new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

        /**
         * Called when a drawer has settled in a completely closed
         * state.
         */
        @Override
        public void onDrawerClosed(final View drawerView) {
            refreshActionBarTitle();
        }

        /**
         * Called when a drawer has settled in a completely open
         * state.
         */
        @Override
        public void onDrawerOpened(final View drawerView) {
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            actionBar.setDisplayShowCustomEnabled(true);
            actionBar.setTitle(R.string.app_name);//ZV
            //mTextView.setText(R.string.app_name); ZV
        }
    };
}

From source file:com.esri.arcgisruntime.sample.offlinegeocode.MainActivity.java

private void setSearchView() {

    mSearchview = (SearchView) findViewById(R.id.searchView1);
    mSearchview.setIconifiedByDefault(true);
    mSearchview.setQueryHint(getResources().getString(R.string.search_hint));
    mSearchview.setOnQueryTextListener(new OnQueryTextListener() {
        @Override//from w  w w  .  ja v  a2 s .co  m
        public boolean onQueryTextSubmit(String query) {
            hideKeyboard();
            geoCodeTypedAddress(query);
            mSearchview.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });

    mSpinner = (Spinner) findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            android.R.layout.simple_spinner_dropdown_item) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            View v = super.getView(position, convertView, parent);
            if (position == getCount()) {
                mSearchview.clearFocus();
            }

            return v;
        }

        @Override
        public int getCount() {
            return super.getCount() - 1; // you dont display last item. It is used as hint.
        }

    };

    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    adapter.addAll(getResources().getStringArray(R.array.suggestion_items));

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // set vertical offset to spinner dropdown for API less than 21
        mSpinner.setDropDownVerticalOffset(80);
    }
    // Apply the adapter to the spinner
    mSpinner.setAdapter(adapter);
    mSpinner.setSelection(adapter.getCount());

    mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == adapter.getCount()) {
                mSearchview.clearFocus();
            } else {
                hideKeyboard();
                mSearchview.setQuery(getResources().getStringArray(R.array.suggestion_items)[position], false);
                geoCodeTypedAddress(getResources().getStringArray(R.array.suggestion_items)[position]);
                mSearchview.setIconified(false);
                mSearchview.clearFocus();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

}

From source file:gr.scify.newsum.ui.SearchViewActivity.java

private void initTopicSpinner() {
    // Get topics in category. Null accepts all user sources. Modify
    // according to user selection
    final String[] saTopicIDs = SearchTopicActivity.saTopicIDs;
    final String[] saTitles = SearchTopicActivity.saTopicTitles;
    final String[] saDates = SearchTopicActivity.saTopicDates;
    // TODO add TopicInfo for SearchResults as well and parse accordingly

    // final String[] saTopicIDs = extras.getStringArray("searchresults");
    final TextView title = (TextView) findViewById(R.id.title);
    // Fill topic spinner
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            android.R.layout.simple_spinner_item, saTitles);

    final TextView tx = (TextView) findViewById(R.id.textView1);
    // tx.setMovementMethod(LinkMovementMethod.getInstance());
    //      final float minm = tx.getTextSize();
    //      final float maxm = (minm + 24);

    // create an invisible spinner just to control the summaries of the
    // category (i will use it later on Swipe)
    Spinner spinner = (Spinner) findViewById(R.id.spinner1);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);//from   w ww. j ava2s .  c om

    // Scroll view init
    final ScrollView scroll = (ScrollView) findViewById(R.id.scrollView1);
    // Add selection event
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            // Show waiting dialog
            showWaitingDialog();

            // Changing summary
            loading = true;
            // Update visibility of rating bar
            final RatingBar rb = (RatingBar) findViewById(R.id.ratingBar);
            rb.setRating(0.0f);
            rb.setVisibility(View.VISIBLE);
            final TextView rateLbl = (TextView) findViewById(R.id.rateLbl);
            rateLbl.setVisibility(View.VISIBLE);

            scroll.scrollTo(0, 0);
            //            String[] saTopicIDs = sTopicIds.split(sSeparator);

            SharedPreferences settings = getSharedPreferences("urls", 0);
            // get user settings for sources
            String UserSources = settings.getString("UserLinks", "All");
            String[] Summary = NewSumServiceClient.getSummary(saTopicIDs[arg2], UserSources);
            if (Summary.length == 0) { // WORK. Updated: CHECK
                // Close waiting dialog
                closeWaitingDialog();

                AlertDialog.Builder alert = new AlertDialog.Builder(SearchViewActivity.this);
                alert.setMessage(R.string.shouldReloadSummaries);
                alert.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface arg0, int arg1) {
                        startActivity(new Intent(getApplicationContext(), NewSumUiActivity.class)
                                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
                    }
                });
                alert.setCancelable(false);
                alert.show();
                loading = false;
                return;
            }
            // track summary views per Search and topic title
            if (getAnalyticsPref()) {
                EasyTracker.getTracker().sendEvent(VIEW_SUMMARY_ACTION, "From Search",
                        saTitles[arg2] + ": " + saDates[arg2], 0l);
            }
            // Generate summary text
            sText = ViewActivity.generateSummaryText(Summary, SearchViewActivity.this);
            pText = ViewActivity.generatesummarypost(Summary, SearchViewActivity.this);
            tx.setText(Html.fromHtml(sText));
            tx.setMovementMethod(LinkMovementMethod.getInstance());
            title.setText(saTitles[arg2] + ": " + saDates[arg2]);
            float defSize = tx.getTextSize();
            SharedPreferences usersize = getSharedPreferences("textS", 0);
            float newSize = usersize.getFloat("size", defSize);
            tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, newSize);
            // update the TopicActivity with viewed item
            TopicActivity.addVisitedTopicID(saTopicIDs[arg2]);

            // Close waiting dialog
            closeWaitingDialog();

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }

    });

}

From source file:edu.ttu.spm.cheapride.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // Retrieve location and camera position from saved instance state.
    if (savedInstanceState != null) {
        mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION);
        mCameraPosition = savedInstanceState.getParcelable(KEY_CAMERA_POSITION);
    }/* w ww .  j a  va2 s . co m*/

    // Retrieve the content view that renders the map.
    setContentView(R.layout.activity_main);

    // Build the Play services client for use by the Fused Location Provider and the Places API.
    // Use the addApi() method to request the Google Places API and the Fused Location Provider.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addConnectionCallbacks(this).addApi(LocationServices.API).addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API).build();
    mGoogleApiClient.connect();

    //        autocompleteFragment = (PlaceAutocompleteFragment)
    //                getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

    loginTextView = (TextView) findViewById(R.id.login);
    registerTextView = (TextView) findViewById(R.id.register);
    loginSeparatorTextView = (TextView) findViewById(R.id.login_separator);
    welcomeTextView = (TextView) findViewById(R.id.welcome_message);
    history = (TextView) findViewById(R.id.history);
    comparisonChart = findViewById(R.id.comparison_chart);
    rideBooking = findViewById(R.id.ride_booking);
    rideBooking.setVisibility(View.INVISIBLE);
    driveInfoBoard = findViewById(R.id.driverInfoBoard);
    bookingButtons = findViewById(R.id.bookingButtons);
    bookingButtons.setVisibility(View.INVISIBLE);
    vehicleImage = (ImageView) findViewById(R.id.vehicleImg);
    vehicleColor = (TextView) findViewById(R.id.vehicleColor);
    vehiclePlateLicense = (TextView) findViewById(R.id.vehiclePlateLicense);
    vehicleInfo = (TextView) findViewById(R.id.vehicleInfo);
    driverImage = (ImageView) findViewById(R.id.driverImg);
    driverName = (TextView) findViewById(R.id.driverName);
    driverInfo = (TextView) findViewById(R.id.driverInfo);

    uberArrivalTime = (TextView) findViewById(R.id.uber_arrival);
    lyftArrivalTime = (TextView) findViewById(R.id.lyft_arrival);
    uberCost = (TextView) findViewById(R.id.uber_cost);
    lyftCost = (TextView) findViewById(R.id.lyft_cost);
    textView_seekBar = (EditText) findViewById(R.id.textView_seekBar);

    carTypeSelection = (Spinner) findViewById(R.id.carType);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this,
            android.R.layout.simple_spinner_item, CAR_TYPES);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    carTypeSelection.setAdapter(adapter);
    carTypeSelection.setOnItemSelectedListener(this);

    bookingHandler = new BookingHandler(this);

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
    ImageLoader.getInstance().init(config);
    imageLoader = ImageLoader.getInstance();

    geocoder = new Geocoder(this, Locale.getDefault());

    main = this;

    setDefaultDate();

    showDialogOnTextViewClick();

}

From source file:com.example.yudiandrean.socioblood.Register.java

/**
 * Called when the activity is first created.
 *//*from   w ww  .  j av  a2 s  .c  om*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register);

    /**
     * Defining all layout items
     **/
    inputFirstName = (EditText) findViewById(R.id.firstname);
    inputLastName = (EditText) findViewById(R.id.lastname);
    inputUsername = (EditText) findViewById(R.id.username);
    inputEmail = (EditText) findViewById(R.id.email);
    inputPassword = (EditText) findViewById(R.id.password);
    btnRegister = (Button) findViewById(R.id.register);
    registerErrorMsg = (TextView) findViewById(R.id.register_error);

    //Blood type spinner
    inputBloodType = (Spinner) findViewById(R.id.bloodtype_spinner);

    ArrayAdapter<String> bloodadapter = new ArrayAdapter<String>(Register.this,
            android.R.layout.simple_spinner_dropdown_item) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            View v = super.getView(position, convertView, parent);
            if (position == getCount()) {
                ((TextView) v.findViewById(android.R.id.text1)).setText("");
                ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
            }
            return v;
        }

        @Override
        public int getCount() {
            return super.getCount() - 1; // you dont display last item. It is used as hint.
        }
    };

    bloodadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bloodadapter.add("O");
    bloodadapter.add("A");
    bloodadapter.add("B");
    bloodadapter.add("AB");
    bloodadapter.add("Blood Type");
    inputBloodType.setAdapter(bloodadapter);
    inputBloodType.setSelection(bloodadapter.getCount()); //display hint

    //Rhesus spinner
    inputRhesus = (Spinner) findViewById(R.id.rhesus_spinner);
    ArrayAdapter<String> rhesusadapter = new ArrayAdapter<String>(Register.this,
            android.R.layout.simple_spinner_dropdown_item) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            View v = super.getView(position, convertView, parent);
            if (position == getCount()) {
                ((TextView) v.findViewById(android.R.id.text1)).setText("");
                ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
            }

            return v;
        }

        @Override
        public int getCount() {
            return super.getCount() - 1; // you dont display last item. It is used as hint.
        }

    };

    rhesusadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    rhesusadapter.add("+");
    rhesusadapter.add("-");
    rhesusadapter.add("Rhesus");

    inputRhesus.setAdapter(rhesusadapter);
    inputRhesus.setSelection(rhesusadapter.getCount()); //display hint

    inputGender = (Spinner) findViewById(R.id.gender_spinner);
    ArrayAdapter<String> genderadapter = new ArrayAdapter<String>(Register.this,
            android.R.layout.simple_spinner_dropdown_item) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            View v = super.getView(position, convertView, parent);
            if (position == getCount()) {
                ((TextView) v.findViewById(android.R.id.text1)).setText("");
                ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
            }

            return v;
        }

        @Override
        public int getCount() {
            return super.getCount() - 1; // you dont display last item. It is used as hint.
        }

    };

    genderadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    genderadapter.add("Male");
    genderadapter.add("Female");
    genderadapter.add("Gender");

    inputGender.setAdapter(genderadapter);
    inputGender.setSelection(genderadapter.getCount()); //display hint

    /**
     * Gets spinner value
     */

    // Session manager
    session = new SessionManager(getApplicationContext());

    // Check if user is already logged in or not
    if (session.isLoggedIn()) {
        // User is already logged in. Take him to main activity
        Intent intent = new Intent(Register.this, UserPanel.class);
        startActivity(intent);
        finish();
    }

    /**
     * Button which Switches back to the login screen on clicked
     **/

    login = (Button) findViewById(R.id.bktologin);
    login.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), LoginActivity.class);
            startActivityForResult(myIntent, 0);
            finish();
        }

    });

    /**
     * Register Button click event.
     * A Toast is set to alert when the fields are empty.
     * Another toast is set to alert Username must be 5 characters.
     **/

    btnRegister.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            if ((!inputUsername.getText().toString().equals(""))
                    && (!inputPassword.getText().toString().equals(""))
                    && (!inputFirstName.getText().toString().equals(""))
                    && (!inputLastName.getText().toString().equals(""))
                    && (!inputEmail.getText().toString().equals(""))
                    && (!inputBloodType.getSelectedItem().toString().equals(""))
                    && (!inputRhesus.getSelectedItem().toString().equals(""))
                    && (!inputGender.getSelectedItem().toString().equals(""))) {
                if (inputUsername.getText().toString().length() > 4) {
                    NetAsync(view);

                } else {
                    Toast.makeText(getApplicationContext(), "Username must be a minimum of 5 characters",
                            Toast.LENGTH_SHORT).show();
                }
            }

            else {
                Toast.makeText(getApplicationContext(), "One or more fields are empty", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });
}

From source file:com.markupartist.sthlmtraveling.PlannerFragment.java

public void initViews() {
    mSearchView = getActivity().getLayoutInflater().inflate(R.layout.search, null);
    getListView().addHeaderView(mSearchView, null, false);

    final TextView historyView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.header, null);
    historyView.setText(R.string.history_label);
    historyView.setOnClickListener(null); // Makes the header un-clickable, hack!
    getListView().addHeaderView(historyView);

    // Hide dividers on the header view.
    getListView().setHeaderDividersEnabled(false);

    if (!mStartPoint.hasName()) {
        mStartPoint.setName(Site.TYPE_MY_LOCATION);
    }//from  w  w w  .  j  a  va2s.c o m
    mStartPointAutoComplete = createAutoCompleteTextView(R.id.from, /*R.id.from_progress*/ -1, mStartPoint);
    mEndPointAutoComplete = createAutoCompleteTextView(R.id.to, /*R.id.to_progress*/ -1, mEndPoint);
    mViaPointAutoComplete = createAutoCompleteTextView(R.id.via, /*R.id.via_progress*/ -1, mViaPoint, true);

    try {
        mHistoryDbAdapter = new HistoryDbAdapter(getActivity()).open();
    } catch (final Exception e) {
        showDialog(createDialogReinstallApp());
        return;
    }

    // Setup view for choosing other data for start and end point.
    final ImageButton fromDialog = (ImageButton) mSearchView.findViewById(R.id.from_menu);
    fromDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mStartPointAutoComplete.setError(null);
            showDialog(createDialogStartPoint());
        }
    });
    final ImageButton toDialog = (ImageButton) mSearchView.findViewById(R.id.to_menu);
    toDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mEndPointAutoComplete.setError(null);
            showDialog(createDialogEndPoint());
        }
    });
    final ImageButton viaDialog = (ImageButton) mSearchView.findViewById(R.id.via_menu);
    viaDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mViaPointAutoComplete.setError(null);
            showDialog(createDialogViaPoint());
        }
    });
    // Views for date and time
    mChangeTimeLayout = (LinearLayout) mSearchView.findViewById(R.id.planner_change_time_layout);

    mDateButton = (Button) mSearchView.findViewById(R.id.planner_route_date);
    mDateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            showDialog(createDialogDate());
        }
    });

    mTimeButton = (Button) mSearchView.findViewById(R.id.planner_route_time);
    mTimeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            showDialog(createDialogTime());
        }
    });

    // Views for radio buttons
    final RadioButton nowRadioButton = (RadioButton) mSearchView.findViewById(R.id.planner_check_now);
    nowRadioButton.setOnCheckedChangeListener(this);
    final RadioButton laterRadioButton = (RadioButton) mSearchView
            .findViewById(R.id.planner_check_more_choices);
    laterRadioButton.setOnCheckedChangeListener(this);

    mWhenSpinner = (Spinner) mSearchView.findViewById(R.id.departure_arrival_choice);
    final ArrayAdapter<CharSequence> whenChoiceAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.when_choice, android.R.layout.simple_spinner_item);
    whenChoiceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mWhenSpinner.setAdapter(whenChoiceAdapter);

    // Handle create shortcut.
    if (mCreateShortcut) {
        registerScreen("Planner create shortcut");
        getActivity().setTitle(R.string.create_shortcut_label);

        // Add search label to button

        RadioGroup chooseTimeGroup = (RadioGroup) mSearchView.findViewById(R.id.planner_choose_time_group);
        chooseTimeGroup.setVisibility(View.GONE);
        historyView.setVisibility(View.GONE);
        // Fake an adapter. This needs to be fixed later on so we can use the history.
        setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.journey_history_row));
    } else {
        setListAdapter(mAdapter);
    }
}