Example usage for android.widget ArrayAdapter ArrayAdapter

List of usage examples for android.widget ArrayAdapter ArrayAdapter

Introduction

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

Prototype

public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects) 

Source Link

Document

Constructor

Usage

From source file:com.vmihalachi.turboeditor.fragment.NavigationDrawerListFragment.java

private void refreshList() {
    // File paths saved in preferences
    String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity());
    // File names for the list
    fileNames = new ArrayList<String>(savedPaths.length);
    // StringBuilder that will contain the file paths
    StringBuilder sb = new StringBuilder();
    // for cycle to convert paths to names
    for (String path : savedPaths) {
        File file = new File(path);
        // Check that the file exist
        if (file.exists()) {
            fileNames.add(FilenameUtils.getName(path));
            sb.append(path).append(",");
        }//from  w ww.  j a  va  2 s  . c o m
    }
    // save list without empty or non existed files
    PreferenceHelper.setSavedPaths(getActivity(), sb);
    // Adapter
    arrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.item_drawer_list, fileNames);
    // Set adapter
    setListAdapter(arrayAdapter);
}

From source file:com.emobc.android.activities.generators.FormActivityGenerator.java

private View insertPickerField(Activity activity, FormDataItem dataItem) {
    Spinner spinner = new Spinner(activity);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item,
            dataItem.getParameters());/* www .  j  a v  a2s  .c  om*/
    spinner.setAdapter(adapter);
    return spinner;
}

From source file:com.cm.android.beercellar.ui.ImageDetailFragment.java

@Override
public void onStart() {
    super.onStart();
    new android.os.AsyncTask<Object, Void, Void>() {
        @Override/* ww  w  .  j  a  va  2 s .c  o  m*/
        protected Void doInBackground(Object... params) {

            try {
                //GA
                mTracker.setScreenName("ImageDetail");
                mTracker.send(new HitBuilders.ScreenViewBuilder().build());
            } catch (Throwable e) {
                //do nothing
            } finally {
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            //AdMob
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest);
            //beer adapter
            mBeer.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.list_item, Utils.BEERS));
        }
    }.execute();
    //display the other contents
    mRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
        @Override
        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {

        }
    });

    mSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mVibrator.vibrate(250);
            save();
            getActivity().finish();
        }
    });
    load();

}

From source file:com.mobicage.rogerthat.registration.OauthRegistrationActivity.java

private void addRegisterDeviceHandler() {
    mWiz.addPageHandler(new Wizard.PageHandler() {
        @Override/*w  ww  .j a v  a2 s .co  m*/
        public void pageDisplayed(Button back, Button next, ViewFlipper switcher) {
            final FSListView deviceList = (FSListView) findViewById(R.id.devices_list);
            final Button registerBtn = (Button) findViewById(R.id.registration_devices_register);
            final Button cancelBtn = (Button) findViewById(R.id.registration_devices_cancel);

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(OauthRegistrationActivity.this,
                    R.layout.list_item, mWiz.getDeviceNames());
            deviceList.setAdapter(adapter);

            registerBtn.setEnabled(true);
            cancelBtn.setEnabled(true);

            ((TextView) findViewById(R.id.registration_devices_text))
                    .setText(getString(R.string.device_unregister_others));
        }

        @Override
        public String getTitle() {
            return null;
        }

        @Override
        public boolean beforeNextClicked(Button back, Button next, ViewFlipper switcher) {
            return false;
        }

        @Override
        public boolean beforeBackClicked(Button back, Button next, ViewFlipper switcher) {
            return false;
        }
    });
}

From source file:de.Maxr1998.xposed.maxlock.ui.settings.appslist.AppsListFragment.java

@SuppressLint("WorldReadableFiles")
@Override/*from ww w . ja  v a  2 s  .c om*/
public boolean onOptionsItemSelected(MenuItem item) {
    if (pref.getBoolean(Common.ENABLE_PRO, false)) {
        final File prefsPackagesFileShort = new File(Common.PREFS_PACKAGES + ".xml");
        final File prefsPerAppFileShort = new File(Common.PREFS_PER_APP + ".xml");
        final File prefsPackagesFile = new File(getActivity().getApplicationInfo().dataDir + File.separator
                + "shared_prefs" + File.separator + prefsPackagesFileShort);
        final File prefsPerAppFile = new File(getActivity().getApplicationInfo().dataDir + File.separator
                + "shared_prefs" + File.separator + prefsPerAppFileShort);
        final File backupDir = new File(
                Environment.getExternalStorageDirectory() + File.separator + "MaxLock_Backup");

        switch (item.getItemId()) {
        case R.id.toolbar_backup_list:
            File curTimeDir = new File(backupDir + File.separator
                    + new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss", Locale.getDefault())
                            .format(new Date(System.currentTimeMillis()))
                    + File.separator);
            try {
                if (prefsPackagesFile.exists()) {
                    FileUtils.copyFileToDirectory(prefsPackagesFile, curTimeDir);
                    if (prefsPerAppFile.exists())
                        FileUtils.copyFileToDirectory(prefsPerAppFile, curTimeDir);
                } else
                    Toast.makeText(getActivity(), R.string.toast_no_files_to_backup, Toast.LENGTH_SHORT).show();
            } catch (IOException e) {
                Toast.makeText(getActivity(), R.string.toast_backup_restore_exception, Toast.LENGTH_SHORT)
                        .show();
                e.printStackTrace();
            }
            if (curTimeDir.exists() && new File(curTimeDir + File.separator + prefsPackagesFileShort).exists())
                Toast.makeText(getActivity(), R.string.toast_backup_success, Toast.LENGTH_SHORT).show();
            return true;

        case R.id.toolbar_restore_list:
            List<String> list = new ArrayList<>(Arrays.asList(backupDir.list()));
            restoreAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, list);
            restoreDialog = new AlertDialog.Builder(getActivity())
                    .setTitle(R.string.dialog_restore_list_message)
                    .setAdapter(restoreAdapter, new DialogInterface.OnClickListener() {
                        @SuppressLint("InlinedApi")
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            File restorePackagesFile = new File(backupDir + File.separator
                                    + restoreAdapter.getItem(i) + File.separator + prefsPackagesFileShort);
                            File restorePerAppFile = new File(backupDir + File.separator
                                    + restoreAdapter.getItem(i) + File.separator + prefsPerAppFileShort);
                            if (restorePackagesFile.exists()) {
                                try {
                                    //noinspection ResultOfMethodCallIgnored
                                    prefsPackagesFile.delete();
                                    FileUtils.copyFile(restorePackagesFile, prefsPackagesFile);
                                    if (restorePerAppFile.exists()) {
                                        //noinspection ResultOfMethodCallIgnored
                                        prefsPerAppFile.delete();
                                        FileUtils.copyFile(restorePerAppFile, prefsPerAppFile);
                                    }
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                                getActivity().getSharedPreferences(Common.PREFS_PACKAGES,
                                        Context.MODE_MULTI_PROCESS);
                                getActivity().getSharedPreferences(Common.PREFS_PER_APP,
                                        Context.MODE_MULTI_PROCESS);
                                Toast.makeText(getActivity(), R.string.toast_restore_success,
                                        Toast.LENGTH_SHORT).show();
                                ((SettingsActivity) getActivity()).restart();
                            } else
                                Toast.makeText(getActivity(), R.string.toast_no_files_to_restore,
                                        Toast.LENGTH_SHORT).show();
                        }
                    }).setNegativeButton(android.R.string.cancel, null).show();
            restoreDialog.getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                    try {
                        FileUtils.deleteDirectory(
                                new File(backupDir + File.separator + restoreAdapter.getItem(i)));
                        restoreAdapter.remove(restoreAdapter.getItem(i));
                        restoreAdapter.notifyDataSetChanged();
                    } catch (IOException e) {
                        e.printStackTrace();
                        return false;
                    }
                    return true;
                }
            });
            return true;
        case R.id.toolbar_clear_list:
            //noinspection deprecation
            getActivity().getSharedPreferences(Common.PREFS_PACKAGES, Context.MODE_WORLD_READABLE).edit()
                    .clear().commit();
            //noinspection deprecation
            getActivity().getSharedPreferences(Common.PREFS_PER_APP, Context.MODE_WORLD_READABLE).edit().clear()
                    .commit();
            ((SettingsActivity) getActivity()).restart();
        }
    } else
        Toast.makeText(getActivity(), R.string.toast_pro_required, Toast.LENGTH_SHORT).show();
    return super.onOptionsItemSelected(item);
}

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

private void inflateLoansProductSpinner() {
    showProgress(true);//  www  . ja va2  s. c o m
    App.apiManager.getAllLoans(new Callback<List<ProductLoans>>() {

        @Override
        public void success(List<ProductLoans> loans, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            final List<String> loansList = new ArrayList<String>();
            for (ProductLoans loansname : loans) {
                loansList.add(loansname.getName());
                loansNameIdHashMap.put(loansname.getName(), loansname.getId());
            }
            ArrayAdapter<String> loansAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item,
                    loansList);
            loansAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
            sp_lproduct.setAdapter(loansAdapter);
            sp_lproduct.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    productId = loansNameIdHashMap.get(loansList.get(i));
                    Log.d("productId " + loansList.get(i), String.valueOf(productId));
                    if (productId != -1) {

                        inflateLoanPurposeSpinner();
                        inflateFrequencyPeriodSpinner();
                        inflateAmortizationSpinner();
                        inflateInterestCalculationPeriodSpinner();
                        //inflaterepaymentFrequencyTypeOptionsSpinner();
                        inflatetransactionProcessingStrategySpinner();
                    } else {

                        Toast.makeText(getActivity(), getString(R.string.error_select_loan), 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.code.android.vibevault.SearchScreen.java

/** Called when the activity is first created. */
@Override//from www .  j  a  v a2  s  .c  o m
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_screen);

    this.searchList = (ListView) this.findViewById(R.id.ResultsListView);
    this.artistSearchInput = (AutoCompleteTextView) this.findViewById(R.id.ArtistSearchBox);
    this.yearSearchInput = (EditText) this.findViewById(R.id.YearSearchBox);
    this.dateModifierSpinner = (Spinner) this.findViewById(R.id.DateSearchSpinner);
    this.searchButton = (Button) this.findViewById(R.id.SearchButton);
    this.settingsButton = (Button) this.findViewById(R.id.SettingsButton);
    //this.searchMoreButton = (Button) this.findViewById(R.id.SearchMoreButton);
    this.clearButton = (Button) this.findViewById(R.id.ClearButton);
    this.searchDrawer = (SlidingDrawer) this.findViewById(R.id.SlidingDrawerSearchScreen);
    this.handleText = (TextView) this.findViewById(R.id.HandleTextView);

    vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);

    searchList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Show");
            menu.add(Menu.NONE, VibeVault.SHOW_INFO, Menu.NONE, "Show Info");
            menu.add(Menu.NONE, VibeVault.ADD_TO_FAVORITE_LIST, Menu.NONE, "Bookmark Show");
        }
    });

    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof JSONQueryTask) {

        workerTask = (JSONQueryTask) retained;
        workerTask.setActivity(this);
    } else {
        workerTask = new JSONQueryTask(this);
    }
    if (VibeVault.searchResults.size() != 0) {
        searchButton.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.morebutton),
                null, null, null);
        searchButton.setText("More");
        //this.clearButton.setEnabled(true);
    } else {
        searchButton.setCompoundDrawablesWithIntrinsicBounds(
                getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null);
        searchButton.setText("Search");
    }
    this.init();

    Intent intent = getIntent();
    if (intent.hasExtra("Artist")) {
        browseArtist(intent.getStringExtra("Artist"));
    }

    if (!VibeVault.db.getPref("artistUpdate").equals("2010-01-01")) {
        artistSearchInput.setAdapter(
                new ArrayAdapter<String>(this, R.layout.artist_search_row, VibeVault.db.getArtistsStrings()));
    }

    if (VibeVault.searchPref.equals("Show/Artist Description") && artistSearchInput.getText().equals("")) {
        artistSearchInput.setHint("Search Descriptions...");
    }
}

From source file:com.example.android.navigationdrawerexample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.enableDefaults(); //STRICT MODE ENABLED

    db = new DBHelper(this);
    session = new Session(getApplicationContext());

    inflatedView = getLayoutInflater().inflate(R.layout.full_layout, null);
    mTitle = mDrawerTitle = getTitle();//from w w  w.j  a  v a2  s  .  com
    login_layout = (RelativeLayout) findViewById(R.id.login_layout);
    //   order_list_layout= (RelativeLayout) findViewById(R.id.order_list_layout);
    signup_layout = (RelativeLayout) findViewById(R.id.signup_layout);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    actionBar = getActionBar();

    text = (TextView) inflatedView.findViewById(R.id.user_name);
    login_option = (TextView) inflatedView.findViewById(R.id.textView1);

    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    order_list = (ListView) findViewById(R.id.order_list);

    final LayoutInflater factory = getLayoutInflater();

    final View vendor_menu = factory.inflate(R.layout.vendor_menu, null);
    final View order_menu = factory.inflate(R.layout.my_order, null);
    menu_list = (ListView) vendor_menu.findViewById(R.id.menu_list);
    // loginPopup= (TextView) vendor_menu.findViewById(R.id.menu_title);
    // Log.d
    //menu_list.addView(order_menu,0);

    Signup = (Button) findViewById(R.id.Signup);
    Gosignup = (Button) findViewById(R.id.Gosignup);
    Login = (ImageButton) findViewById(R.id.Login);

    Sign_username = (EditText) findViewById(R.id.SignUsername);
    Sign_name = (EditText) findViewById(R.id.vendor);
    Sign_pass = (EditText) findViewById(R.id.SignPass);
    Sign_cpass = (EditText) findViewById(R.id.SignCpass);
    Sign_phone = (EditText) findViewById(R.id.Phone);

    Login_pass = (EditText) findViewById(R.id.Logpass);
    Login_email = (EditText) findViewById(R.id.Logusername);

    // Log_username= (EditText) findViewById(R.id.Logusername);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    adapter = new MyAdapter(this);
    //adapter2=new MyAdapter2(this);
    // menu_adapter=new MyAdapter2(this);
    mDrawerList.setAdapter(adapter);
    mDrawerList.setDividerHeight(0);
    //mDrawerList.setAdapter(adapter);
    // order_list.setAdapter(adapter2);
    // menu_list.setAdapter(menu_adapter);

    menu_list.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, adapter.mPlanetTitles));

    ImageView floatoption = new ImageView(this);
    floatoption.setImageResource(R.drawable.foption);

    ImageView floatadd = new ImageView(this);
    floatadd.setImageResource(R.drawable.fplus);

    floatin = new ImageView(this);
    floatin.setImageResource(R.drawable.flogin);

    floatout = new ImageView(this);
    floatout.setImageResource(R.drawable.flogout);

    ImageView floatrefresh = new ImageView(this);
    floatrefresh.setImageResource(R.drawable.refresh);

    itemBuilder = new SubActionButton.Builder(this);

    loginout = itemBuilder.setContentView(floatin).build();
    refresh = itemBuilder.setContentView(floatrefresh).build();
    additem = itemBuilder.setContentView(floatadd).build();

    actionButton = new FloatingActionButton.Builder(this).setContentView(floatoption).build();

    actionMenu = new FloatingActionMenu.Builder(this).addSubActionView(loginout).addSubActionView(additem)
            .addSubActionView(refresh)

            // ...
            .attachTo(actionButton).build();

    Signup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            View v = mDrawerList.getChildAt(0);
            View v2 = mDrawerList.getChildAt(5);

            text = (TextView) v.findViewById(R.id.user_name);
            login_option = (TextView) v2.findViewById(R.id.textView1);
            profile = (ImageView) v.findViewById(R.id.user_image);
            profile.setImageResource(R.drawable.welcome);
            text.setTextSize(20);
            text.setTextColor(Color.MAGENTA);
            text.setText("" + Sign_name.getText().toString());

            login_option.setText("Logout");

            floatout.setImageResource(R.drawable.flogout);
            // loginout.setContentView(floatout);
            long id = db.Insert(Sign_username.getText().toString(), Sign_name.getText().toString(),
                    Sign_pass.getText().toString(), Sign_phone.getText().toString());

            Log.d("This is-----------==", (String) text.getText() + id);

            //mDrawerList.invalidateViews();

            //mDrawerList.removeViewAt(0);
            adapter.notifyDataSetChanged();

            loginout.removeView(floatin);
            loginout.setContentView(floatout);

            order_list.setVisibility(View.VISIBLE);
            signup_layout.setVisibility(View.INVISIBLE);
            login_layout.setVisibility(View.INVISIBLE);

        }
    });

    Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            user_name = Login_email.getText().toString();
            user_pass = Login_pass.getText().toString();

            new GetAllCustomerTask().execute(new ApiConnector());
            new Order_details().execute(new ApiConnector());

        }
    });

    if (!session.getusename().equals("")) {
        user_id = session.getusename();
        user_name = session.getusename();
        user_pass = session.getpassword();
        login_layout.setVisibility(View.INVISIBLE);
        new GetAllCustomerTask().execute(new ApiConnector());
        // new Order_details().execute(new ApiConnector());
        // View vt = mDrawerList.getChildAt(0);
        //login_check(jsonArray);

        //new Order_details().execute(new ApiConnector());
    }

    additem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logged_in) {
                Intent i = new Intent(getApplicationContext(), Add_Item.class);
                startActivity(i);
            } else
                Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show();

        }
    });
    loginout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logged_in) {
                session.setusename("", "");
                finish();
                startActivity(getIntent());
                Toast.makeText(getApplicationContext(), "You are Loged Out", Toast.LENGTH_SHORT).show();
            } else
                Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show();

        }
    });

    Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            user_name = Login_email.getText().toString();
            user_pass = Login_pass.getText().toString();
            new GetAllCustomerTask().execute(new ApiConnector());
            //   new Order_details().execute(new ApiConnector());

        }
    });

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    order_list.setOnItemClickListener(new OrderItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF3BBD8F));

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            text = (TextView) inflatedView.findViewById(R.id.user_name);
            Log.d("Thit is----------------", (String) text.getText());
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }

}

From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.poi_map, menu);

    miSearch = menu.findItem(R.id.action_search);
    miDirections = menu.findItem(R.id.action_directions);
    miPlay = menu.findItem(R.id.action_play);

    String[] poiNames = new String[gmm.pois.size()];
    for (int i = 0; i < gmm.pois.size(); i++) {
        poiNames[i] = gmm.pois.get(i).getName();
    }/*from ww  w  . ja va 2s. c om*/

    searchView = (ArrayAdapterSearchView) (SearchView) MenuItemCompat.getActionView(miSearch);

    mAdapter = new ArrayAdapter<String>(this, R.layout.dropdown_item, poiNames);

    searchView.setAdapter(mAdapter);

    searchView.setThreshold(1); // one letter is enough for auto complete

    searchView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // when clicked on suggested item
            SearchModule.searchGoogleMap(POIMapActivity.this, gmm.googleMap, gmm.pois, searchView,
                    mAdapter.getItem(position).toString());
            MenuItemCompat.collapseActionView(miSearch);

        }
    });

    searchView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // when clicked on search view (e.g. search icon)
            searchView.showDropDown();

        }
    });

    searchView.setQueryHint(POIMapActivity.this.getResources().getString(R.string.search_hint));

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

    if (null != searchView) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false);
    }

    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            // some action if needed
            return true;
        }

        public boolean onQueryTextSubmit(String query) {
            // get entered query value and search
            SearchModule.searchGoogleMap(POIMapActivity.this, gmm.googleMap, gmm.pois, searchView, query);

            MenuItemCompat.collapseActionView(miSearch);

            return true;

        }
    };
    searchView.setOnQueryTextListener(queryTextListener);

    return super.onCreateOptionsMenu(menu);

    // return true;
}

From source file:mtmo.test.mediadrm.MainActivity.java

private void setupDropDownList() {
    mSpinnerABSContentList = (Spinner) findViewById(R.id.dropdownlist_abs_content_id);
    mSpinnerOfflineContentList = (Spinner) findViewById(R.id.dropdownlist_offline_content_id);
    mSpinnerActionTokenList = (Spinner) findViewById(R.id.select);

    if (mSpinnerABSContentList != null) {
        File file = new File(Constants.ABS_CONTENT_LIST);

        if (file.exists()) {
            List<ABSContentInfo> absContentInfo = null;
            try {
                absContentInfo = ABSContentInfo.parseFromProeprties(new FileInputStream(file));
            } catch (FileNotFoundException e) {
                mLogger.e("Could not found : " + Constants.ABS_CONTENT_LIST);
                e.printStackTrace();/*from   www  . j a v a  2s .c o m*/
            }
            if (absContentInfo != null) {
                ArrayAdapter<ABSContentInfo> adapter = new ArrayAdapter<ABSContentInfo>(mContext,
                        android.R.layout.simple_list_item_1, absContentInfo);
                mSpinnerABSContentList.setAdapter(adapter);
            }
        } else {
            mLogger.e("Could not found : " + Constants.ABS_CONTENT_LIST);
        }
    }

    if (mSpinnerOfflineContentList != null) {
        mSpinnerOfflineContentList.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                if (mOfflineFilenames != null && !mOfflineFilenames.isEmpty()) {
                    mCurrentOfflineContentPath = Constants.VIDEO_DIRECTORY_PATH + "/"
                            + mOfflineFilenames.get(arg2);
                }
            }

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

    if (mSpinnerActionTokenList != null) {
        mSpinnerActionTokenList.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                if (mATKNFilenames != null && !mATKNFilenames.isEmpty()) {
                    mCurrentATKNFilePath = Constants.ACTION_DIRECTORY_PATH + "/" + mATKNFilenames.get(arg2);
                }
            }

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