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.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment.java

private void inflateAmortizationSpinner(ResponseBody result) {

    final List<AmortizationType> amortizationType = new ArrayList<>();
    // you can use this array to populate your spinner
    final ArrayList<String> amortizationTypeNames = new ArrayList<String>();
    //Try to get response body
    BufferedReader reader = null;
    StringBuilder sb = new StringBuilder();
    try {/*from  www  .j ava2s .c om*/
        reader = new BufferedReader(new InputStreamReader(result.byteStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }
        JSONObject obj = new JSONObject(sb.toString());
        if (obj.has("amortizationTypeOptions")) {
            JSONArray amortizationTypes = obj.getJSONArray("amortizationTypeOptions");
            for (int i = 0; i < amortizationTypes.length(); i++) {
                JSONObject amortizationTypeObject = amortizationTypes.getJSONObject(i);
                AmortizationType amortization = new AmortizationType();
                amortization.setId(amortizationTypeObject.optInt("id"));
                amortization.setValue(amortizationTypeObject.optString("value"));
                amortizationType.add(amortization);
                amortizationTypeNames.add(amortizationTypeObject.optString("value"));
                amortizationTypeIdHashMap.put(amortization.getValue(), amortization.getId());
            }

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

            } else {

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

            }

        }

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

        }
    });
}

From source file:com.kiwiteam.nomiddleman.LargeGroupActivity.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    int vId = parent.getId();
    switch (vId) {
    case R.id.day:
        String day = parent.getItemAtPosition(position).toString();
        ArrayList<Integer> quantities = tour.getAllTourSessionAvailability(day);

        tQty = (Spinner) findViewById(R.id.quantity);
        qAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, quantities);
        qAdapter.notifyDataSetChanged();

        qAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        tQty.setAdapter(qAdapter);/*  w  ww .  jav  a  2  s. c  o  m*/
        break;
    }
}

From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java

private void populateThirdForm(LinearLayout formLayout) {
    formLayout.addView(createTitle(mContext.getString(R.string.account_create_city_title)));
    EditText cityEditText = createEditText(mContext.getString(R.string.account_create_city_hint),
            InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_DONE, false, CITY_KEY);

    if (mFormData.get(CITY_KEY) != null) {
        cityEditText.setText(mFormData.get(CITY_KEY));
    }/*from w  ww  .jav a2 s  . c  o m*/

    formLayout.addView(cityEditText);
    formLayout.addView(createErrorView(CITY_KEY));

    formLayout.addView(createTitle(mContext.getString(R.string.account_create_country_title)));

    Spinner spinner = new Spinner(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    params.bottomMargin = 17;
    spinner.setLayoutParams(params);

    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item, Countries.COUNTRIES);
    spinner.setAdapter(adapter);
    spinner.setPrompt(mContext.getString(R.string.account_create_country_spinner_prompt));
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

            mFormData.put(COUNTRY_KEY, Countries.COUNTRY_CODES[pos]);
        }

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

    if (mFormData.get(COUNTRY_KEY) != null) {
        List<String> array = Arrays.asList(Countries.COUNTRY_CODES);
        spinner.setSelection(array.indexOf(mFormData.get(COUNTRY_KEY)));
    }

    formLayout.addView(spinner);
}

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

private void inflateLoansProductSpinner() {
    showProgress(true);/*from  w ww .  j  a va  2s.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();
                        inflatetransactionProcessingStrategySpinner();
                        inflateLoanFundSpinner();
                        inflateLoanOfficerSpinner();
                        inflateInterestTypeMethodSpinner();
                    } 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:de.Maxr1998.xposed.maxlock.ui.settings.appslist.AppListFragment.java

@SuppressLint({ "WorldReadableFiles", "CommitPrefEdits" })
@Override/* w ww. ja v  a  2  s  .c o  m*/
public boolean onOptionsItemSelected(MenuItem item) {
    if (prefs.getBoolean(Common.ENABLE_PRO, false) || item.getItemId() == R.id.toolbar_filter_activated) {
        final File prefsPackagesFileShort = new File(Common.PREFS_PACKAGES + ".xml");
        final File prefsPerAppFileShort = new File(Common.PREFS_PER_APP + ".xml");
        final File prefsActivitiesFileShort = new File(Common.PREFS_ACTIVITIES + ".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 prefsActivitiesFile = new File(getActivity().getApplicationInfo().dataDir + File.separator
                + "shared_prefs" + File.separator + prefsActivitiesFileShort);
        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);
            backupFile(prefsPackagesFile, curTimeDir);
            backupFile(prefsPerAppFile, curTimeDir);
            backupFile(prefsActivitiesFile, curTimeDir);
            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);
                            File restoreActivitiesFile = new File(backupDir + File.separator
                                    + restoreAdapter.getItem(i) + File.separator + prefsActivitiesFileShort);
                            if (restorePackagesFile.exists()) {
                                try {
                                    //noinspection ResultOfMethodCallIgnored
                                    prefsPackagesFile.delete();
                                    FileUtils.copyFile(restorePackagesFile, prefsPackagesFile);
                                    if (restorePerAppFile.exists()) {
                                        //noinspection ResultOfMethodCallIgnored
                                        prefsPerAppFile.delete();
                                        FileUtils.copyFile(restorePerAppFile, prefsPerAppFile);
                                    }
                                    if (prefsActivitiesFile.exists()) {
                                        //noinspection ResultOfMethodCallIgnored
                                        prefsActivitiesFile.delete();
                                        FileUtils.copyFile(restoreActivitiesFile, prefsActivitiesFile);
                                    }
                                } 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_setting:
            launchFragment(new SettingsFragment(), true, this);
            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();
            return true;
        case R.id.toolbar_filter_activated:
            String appListFilter = prefs.getString("app_list_filter", "");
            if (appListFilter == null) {
                return true;
            }
            switch (appListFilter) {
            case "@*activated*":
                prefs.edit().putString("app_list_filter", "@*deactivated*").commit();
                break;
            case "@*deactivated*":
                prefs.edit().putString("app_list_filter", "").commit();
                break;
            default:
                prefs.edit().putString("app_list_filter", "@*activated*").commit();
                break;
            }
            filterIcon(item);
            filter();
            return true;
        }
    } else
        Toast.makeText(getActivity(), R.string.toast_pro_required, Toast.LENGTH_SHORT).show();
    return super.onOptionsItemSelected(item);
}

From source file:com.owncloud.android.ui.adapter.FileListListAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;/*from  w w  w. j a v  a  2  s.  co m*/
    if (view == null) {
        LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflator.inflate(R.layout.list_item, null);
    }

    if (mFiles != null && mFiles.size() > position) {
        OCFile file = mFiles.get(position);
        TextView fileName = (TextView) view.findViewById(R.id.Filename);
        String name = file.getFileName();
        if (dataSourceShareFile == null)
            dataSourceShareFile = new DbShareFile(mContext);

        Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
        String[] accountNames = account.name.split("@");

        if (accountNames.length > 2) {
            accountName = accountNames[0] + "@" + accountNames[1];
            url = accountNames[2];
        }
        Map<String, String> fileSharers = dataSourceShareFile.getUsersWhoSharedFilesWithMe(accountName);
        TextView sharer = (TextView) view.findViewById(R.id.sharer);
        ImageView shareButton = (ImageView) view.findViewById(R.id.shareItem);
        fileName.setText(name);
        ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
        fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
        ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
        FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
        if (fileSharers.size() != 0 && (!file.equals("Shared") && file.getRemotePath().contains("Shared"))) {
            if (fileSharers.containsKey(name)) {
                sharer.setText(fileSharers.get(name));
                fileSharers.remove(name);
            } else {
                sharer.setText(" ");
            }
        } else {
            sharer.setText(" ");
        }

        if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.downloading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.uploading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (file.isDown()) {
            localStateView.setImageResource(R.drawable.local_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else {
            localStateView.setVisibility(View.INVISIBLE);
        }

        TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
        TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
        ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
        shareButton.setOnClickListener(new OnClickListener() {
            String shareStatusDisplay;
            int flagShare = 0;

            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(mContext);
                final OCFile fileToBeShared = (OCFile) getItem(position);
                final ArrayAdapter<String> shareWithFriends;
                final ArrayAdapter<String> shareAdapter;
                final String filePath;
                sharedWith = new ArrayList<String>();
                dataSource = new DbFriends(mContext);
                dataSourceShareFile = new DbShareFile(mContext);
                dialog.setContentView(R.layout.share_file_with);
                dialog.setTitle("Share");
                Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
                String[] accountNames = account.name.split("@");

                if (accountNames.length > 2) {
                    accountName = accountNames[0] + "@" + accountNames[1];
                    url = accountNames[2];
                }

                final AutoCompleteTextView textView = (AutoCompleteTextView) dialog
                        .findViewById(R.id.autocompleteshare);
                Button shareBtn = (Button) dialog.findViewById(R.id.ShareBtn);
                Button doneBtn = (Button) dialog.findViewById(R.id.ShareDoneBtn);
                final ListView listview = (ListView) dialog.findViewById(R.id.alreadySharedWithList);

                textView.setThreshold(2);
                final String itemType;

                filePath = "files" + String.valueOf(fileToBeShared.getRemotePath());
                final String fileName = fileToBeShared.getFileName();
                final String fileRemotePath = fileToBeShared.getRemotePath();
                if (dataSourceShareFile == null)
                    dataSourceShareFile = new DbShareFile(mContext);
                sharedWith = dataSourceShareFile.getUsersWithWhomIhaveSharedFile(fileName, fileRemotePath,
                        accountName, String.valueOf(1));
                shareAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        sharedWith);
                listview.setAdapter(shareAdapter);
                final String itemSource;
                if (fileToBeShared.isDirectory()) {
                    itemType = "folder";
                    int lastSlashInFolderPath = filePath.lastIndexOf('/');
                    itemSource = filePath.substring(0, lastSlashInFolderPath);
                } else {
                    itemType = "file";
                    itemSource = filePath;
                }

                //Permissions disabled with friends app
                ArrayList<String> friendList = dataSource.getFriendList(accountName);
                dataSource.close();
                shareWithFriends = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        friendList);
                textView.setAdapter(shareWithFriends);
                textView.setFocusableInTouchMode(true);
                dialog.show();
                textView.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

                    }
                });
                final Handler finishedHandler = new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        shareAdapter.notifyDataSetChanged();
                        Toast.makeText(mContext, shareStatusDisplay, Toast.LENGTH_SHORT).show();

                    }
                };
                shareBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        final String shareWith = textView.getText().toString();

                        if (shareWith.equals("")) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext,
                                    "Please enter the friends name with whom you want to share",
                                    Toast.LENGTH_SHORT).show();
                        } else if (sharedWith.contains(shareWith)) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext, "You have shared the file with that person",
                                    Toast.LENGTH_SHORT).show();
                        } else {

                            textView.setText("");
                            Runnable runnable = new Runnable() {
                                @Override
                                public void run() {
                                    HttpPost post = new HttpPost(
                                            "http://" + url + "/owncloud/androidshare.php");
                                    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();

                                    params.add(new BasicNameValuePair("itemType", itemType));
                                    params.add(new BasicNameValuePair("itemSource", itemSource));
                                    params.add(new BasicNameValuePair("shareType", shareType));
                                    params.add(new BasicNameValuePair("shareWith", shareWith));
                                    params.add(new BasicNameValuePair("permission", permissions));
                                    params.add(new BasicNameValuePair("uidOwner", accountName));
                                    HttpEntity entity;
                                    String shareSuccess = "false";
                                    try {
                                        entity = new UrlEncodedFormEntity(params, "utf-8");
                                        HttpClient client = new DefaultHttpClient();
                                        post.setEntity(entity);
                                        HttpResponse response = client.execute(post);

                                        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                                            HttpEntity entityresponse = response.getEntity();
                                            String jsonentity = EntityUtils.toString(entityresponse);
                                            JSONObject obj = new JSONObject(jsonentity);
                                            shareSuccess = obj.getString("SHARE_STATUS");
                                            flagShare = 1;
                                            if (shareSuccess.equals("true")) {
                                                dataSourceShareFile.putNewShares(fileName, fileRemotePath,
                                                        accountName, shareWith);
                                                sharedWith.add(shareWith);
                                                shareStatusDisplay = "File share succeeded";
                                            } else if (shareSuccess.equals("INVALID_FILE")) {
                                                shareStatusDisplay = "File you are trying to share does not exist";
                                            } else if (shareSuccess.equals("INVALID_SHARETYPE")) {
                                                shareStatusDisplay = "File Share type is invalid";
                                            } else {
                                                shareStatusDisplay = "Share did not succeed. Please check your internet connection";
                                            }

                                            finishedHandler.sendEmptyMessage(flagShare);

                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }

                                }
                            };
                            new Thread(runnable).start();

                        }

                        if (flagShare == 1) {
                        }

                    }

                });
                doneBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                        //dataSourceShareFile.close();
                    }
                });
            }

        });
        //dataSourceShareFile.close();
        if (!file.isDirectory()) {
            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            // this if-else is needed even thoe fav icon is visible by default
            // because android reuses views in listview
            if (!file.keepInSync()) {
                view.findViewById(R.id.imageView3).setVisibility(View.GONE);
            } else {
                view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
            }

            ListView parentList = (ListView) parent;
            if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) {
                checkBoxV.setVisibility(View.GONE);
            } else {
                if (parentList.isItemChecked(position)) {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
                } else {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
                }
                checkBoxV.setVisibility(View.VISIBLE);
            }

        } else {

            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            checkBoxV.setVisibility(View.GONE);
            view.findViewById(R.id.imageView3).setVisibility(View.GONE);
        }
    }

    return view;
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java

private void getAccount() {
    refreshedCount = 0;//from w  ww  .jav  a2  s.  c  o  m
    mPullToRefreshLayout.setRefreshing(true);
    mMenuList = getResources().getStringArray(R.array.accountMenu);
    adapter = new ArrayAdapter<String>(getActivity(), R.layout.drawer_list_item, mMenuList);
    mDrawerList.setAdapter(adapter);
    Fetcher fetcher = new Fetcher(this, "3/account/" + username, ApiCall.GET, null,
            ((ImgurHoloActivity) getActivity()).getApiCall(), ACCOUNTDATA);
    fetcher.execute();
    fetcher = new Fetcher(this, "3/account/" + username + "/likes", ApiCall.GET, null,
            ((ImgurHoloActivity) getActivity()).getApiCall(), LIKEDATA);
    fetcher.execute();
    fetcher = new Fetcher(this, "3/account/" + username + "/images/count", ApiCall.GET, null,
            ((ImgurHoloActivity) getActivity()).getApiCall(), COUNTDATA);
    fetcher.execute();
    fetcher = new Fetcher(this, "3/account/" + username + "/comments/count", ApiCall.GET, null,
            ((ImgurHoloActivity) getActivity()).getApiCall(), COMMENTDATA);
    fetcher.execute();
    fetcher = new Fetcher(this, "/3/account/" + username + "/albums/ids", ApiCall.GET, null,
            ((ImgurHoloActivity) getActivity()).getApiCall(), ALBUMDATA);
    fetcher.execute();
}

From source file:com.eugene.fithealthmaingit.UI.SaveSearchAddItemActivityMain.java

private void findViewsById() {
    mLogAdapterAll = new LogAdapterPrevention(SaveSearchAddItemActivityMain.this, 0,
            LogMeal.logsByDate(new Date()));
    mFatSecretGet = new FatSecretGetMethod(); // method.get
    mViewSevingSize = (TextView) findViewById(R.id.viewSevingSize);
    mViewSevingSize.setVisibility(View.GONE);
    mServingg = (TextView) findViewById(R.id.servingg);
    mServingg.setText("1");
    mAmountPerServing = (TextView) findViewById(R.id.amountPerServing);
    mServingSizeUpdated = (TextView) findViewById(R.id.servingSizeUpdated);
    mFoodCal = (TextView) findViewById(R.id.foodCal);
    mCalUpdate = (TextView) findViewById(R.id.calUpdate);
    mViewFat1 = (TextView) findViewById(R.id.viewFat1);
    mFattieUpdate = (TextView) findViewById(R.id.fattieUpdate);
    mViewSaturatedFat = (TextView) findViewById(R.id.viewSaturatedFat);
    mSaturatedFatUpdate = (TextView) findViewById(R.id.saturatedFatUpdate);
    mViewCholesterol = (TextView) findViewById(R.id.viewCholesterol);
    mCholesterolUpdate = (TextView) findViewById(R.id.cholesterolUpdate);
    mViewSodium = (TextView) findViewById(R.id.viewSodium);
    mSodiumUpdate = (TextView) findViewById(R.id.sodiumUpdate);
    mViewCarbs1 = (TextView) findViewById(R.id.viewCarbs1);
    mCarbUpdate = (TextView) findViewById(R.id.carbUpdate);
    mViewFiber = (TextView) findViewById(R.id.viewFiber);
    mFiberUpdate = (TextView) findViewById(R.id.fiberUpdate);
    mViewSugar = (TextView) findViewById(R.id.viewSugar);
    mSugarUpdate = (TextView) findViewById(R.id.sugarUpdate);
    mViewProtien1 = (TextView) findViewById(R.id.viewProtien1);
    mProUpdate = (TextView) findViewById(R.id.proUpdate);
    mViewVitA = (TextView) findViewById(R.id.viewVitA);
    mVitAUpdate = (TextView) findViewById(R.id.vitAUpdate);
    mViewVitC = (TextView) findViewById(R.id.viewVitC);
    mVitCUpdate = (TextView) findViewById(R.id.vitCUpdate);
    mViewCalcium = (TextView) findViewById(R.id.viewCalcium);
    mCalciumUpdate = (TextView) findViewById(R.id.calciumUpdate);
    mViewIron = (TextView) findViewById(R.id.viewIron);
    mIronUpdate = (TextView) findViewById(R.id.ironUpdate);
    mPbCal = (ProgressBar) findViewById(R.id.pbCal);
    mPbFat = (ProgressBar) findViewById(R.id.pbFat);
    mPbCarb = (ProgressBar) findViewById(R.id.pbCarb);
    mPbPro = (ProgressBar) findViewById(R.id.pbPro);
    mItem = new ArrayList<>();
    servingAdapter = new ArrayAdapter<>(SaveSearchAddItemActivityMain.this, android.R.layout.simple_list_item_1,
            mItem);/*from  w  w w  .j  a va 2s  .c  om*/
    mSpnServings = (Spinner) findViewById(R.id.spnServings);
    mSpnServings.setVisibility(View.GONE);
    mSpnServings.setAdapter(servingAdapter);
    mSpnServings.setSelection(0, false);
    mSpnServings.post(new Runnable() {
        public void run() {
            mSpnServings.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int i, long id) {
                    if (mLastSpinnerPosition == i) { // Prevent spinner from being called on start and reselection of the same item
                        return;
                    }
                    mLastSpinnerPosition = i;
                    getFood(Integer.valueOf(food_id));
                }

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

                }
            });
        }
    });
    llVitA = (LinearLayout) findViewById(R.id.llVitA);
    llVitC = (LinearLayout) findViewById(R.id.llVitC);
    llCalcium = (LinearLayout) findViewById(R.id.llCalcium);
    llIron = (LinearLayout) findViewById(R.id.llIron);
    llCalories = (LinearLayout) findViewById(R.id.llCalories);
    llFat = (LinearLayout) findViewById(R.id.llFat);
    llSat = (LinearLayout) findViewById(R.id.llSat);
    llCholesterol = (LinearLayout) findViewById(R.id.llCholesterol);
    llSodium = (LinearLayout) findViewById(R.id.llSodium);
    llCarbs = (LinearLayout) findViewById(R.id.llCarbs);
    llFiber = (LinearLayout) findViewById(R.id.llFiber);
    llSugars = (LinearLayout) findViewById(R.id.llSugars);
    llProtein = (LinearLayout) findViewById(R.id.llProtein);
    vVitA = findViewById(R.id.vVitA);
    vVitC = findViewById(R.id.vVitC);
    vCalcium = findViewById(R.id.vCalcium);
    vIron = findViewById(R.id.vIron);
    vFat = findViewById(R.id.vFat);
    vSat = findViewById(R.id.vSat);
    vCholesterol = findViewById(R.id.vCholesterol);
    vSodium = findViewById(R.id.vSodium);
    vCarbs = findViewById(R.id.vCarbs);
    vFiber = findViewById(R.id.vFiber);
    vSugar = findViewById(R.id.vSugar);
    vPro = findViewById(R.id.vPro);

    updateItems();
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

private Spinner buildSpinner(Attribute attribute, ViewGroup parent) {

    ViewGroup row = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.input_spinner_view, parent);

    Spinner spinner = (Spinner) row.findViewById(R.id.spinner);
    spinner.setPrompt("Select " + attribute.description);
    ArrayList<AttributeOption> options = new ArrayList<Attribute.AttributeOption>(attribute.options.length + 1);
    options.addAll(Arrays.asList(attribute.options));

    ArrayAdapter<AttributeOption> adapter = new ArrayAdapter<AttributeOption>(viewContext,
            R.layout.multiline_spinner_item, options);
    adapter.setDropDownViewResource(R.layout.multiline_spinner_dropdown_item);
    spinner.setAdapter(adapter);//from   w ww  . ja v  a2  s.c  o m

    return spinner;
}

From source file:com.housekeeper.ar.healthhousekeeper.personalinfo.ModifyInfoActivity.java

private void initData() {
    try {//from   w w  w  . ja v  a2s  .  com
        usernameET.setText(joDoc.getString("userId"));
        //psdET.setText(joDoc.getString(""));
        nameET.setText(joDoc.getString("name"));
        idET.setText(joDoc.getString("identity"));

        telET.setText(joDoc.getString("phone"));
        mailET.setText(joDoc.getString("email"));
        //TODO ?
        //            workIdEditText.setText(joDoc.getString("workID"));

        sexStr = joDoc.getString("sex");
        birthdayStr = joDoc.getString("birthday");
        yearStr = birthdayStr.substring(0, 4);
        monthStr = birthdayStr.substring(5, 7);
        dayStr = birthdayStr.substring(8);
        Log.i(TAG, "yearString " + yearStr + " monthString " + monthStr + " dayString " + dayStr);

    } catch (JSONException e) {
        e.printStackTrace();
    }

    final List<String> yearList = getYearData();
    final List<String> monthList = getMonthData();
    final List<String> dayList = getDayData();
    final List<String> sexList = getSexData();

    ArrayAdapter<String> yearAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            yearList) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(yearList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    ArrayAdapter<String> monthAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            getMonthData()) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(monthList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    ArrayAdapter<String> dayAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            getDayData()) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(dayList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    year.setAdapter(yearAdapter);
    //      year.setSelection(default_year_pos, true);
    month.setAdapter(monthAdapter);
    //      month.setSelection(default_month_pos, true);
    day.setAdapter(dayAdapter);
    //      day.setSelection(default_day_pos, true);

    ArrayAdapter<String> sexAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            getSexData()) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(sexList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    sex.setAdapter(sexAdapter);
    //        sex.setSelection(default_sex_pos, true);

    //      ArrayAdapter<String> proAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item,namePros){
    //         @Override
    //         public View getDropDownView(int position, View convertView, ViewGroup parent) {
    //            LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //            View view = inflater.inflate(R.layout.spinner_item_layout,
    //                  null);
    //            TextView label = (TextView) view
    //                  .findViewById(R.id.spinner_item_label);
    //
    //            label.setText(namePros[position]);
    //
    //
    //            return view;
    //            //return super.getDropDownView(position, convertView, parent);
    //         }
    //      };
    //      //?
    //
    //      proAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
    ////      proAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //      pro.setAdapter(proAdapter);
    //      pro.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    //
    //            @Override
    //            public void onItemSelected(AdapterView<?> parent, View view,
    //                                       int position, long id) {
    //                // TODO Auto-generated method stub
    //                proStr = parent.getItemAtPosition(position).toString();
    //                Log.v(TAG, "selcet proStr:" + proStr);
    //                if (proStr.equals(namePros[position])) {
    //                    idJobTitlesInt = idJobTitles[position];
    //                }
    //            }
    //
    //            @Override
    //            public void onNothingSelected(AdapterView<?> arg0) {
    //                // TODO Auto-generated method stub
    //
    //            }
    //
    //        });
    //        try {
    //            pro.setSelection(joDoc.getInt("jobTitleId")-1,true);
    //        } catch (JSONException e) {
    //            e.printStackTrace();
    //        }

    ArrayAdapter<String> shengAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, nameProvinces) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(nameProvinces[position]);

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    //?

    shengAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
    sheng.setAdapter(shengAdapter);
    sheng.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> shengparent, View shengview, int shengposition,
                long shengid) {
            // TODO Auto-generated method stub
            myApp.setShengposition(shengposition);
            shengStr = shengparent.getItemAtPosition(shengposition).toString();
            Log.v(TAG, "shengStr:" + shengStr);
            if (shengStr.equals(nameProvinces[shengposition])) {
                Log.v(TAG, "position:" + shengposition);
                for (int i = 0; i < joProvinces.length; i++) {
                    try {

                        if (shengStr.equals(joProvinces[i].getString("name"))) {
                            jaCities = joProvinces[i].getJSONArray("cities");
                            joCities = new JSONObject[jaCities.length()];
                            nameCities = new String[joCities.length];

                            for (int j = 0; j < jaCities.length(); j++) {
                                joCities[j] = jaCities.getJSONObject(j);
                                nameCities[j] = joCities[j].getString("name");
                            }
                        }
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block

                        e.printStackTrace();
                    }
                }
            }
            sheng.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {

                    Log.i(TAG, "year touch ");
                    closeSoftKeyboard();
                    return false;
                }
            });
            shiAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item, nameCities) {
                @Override
                public View getDropDownView(int position, View convertView, ViewGroup parent) {
                    LayoutInflater inflater = (LayoutInflater) getContext()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View view = inflater.inflate(R.layout.spinner_item_layout, null);
                    TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

                    label.setText(nameCities[position]);

                    return view;
                    //return super.getDropDownView(position, convertView, parent);
                }
            };

            //?
            shiAdapter.setDropDownViewResource(R.layout.spinner_item_layout);

            //            shiAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            shi.setAdapter(shiAdapter);

            shi.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                @Override
                public void onItemSelected(AdapterView<?> shiparent, View shiview, int shiposition,
                        long shiid) {
                    // TODO Auto-generated method stub
                    shiStr = shiparent.getItemAtPosition(shiposition).toString();
                    Log.v(TAG, "shiStr:" + shiStr);
                    if (shiStr.equals(nameCities[shiposition])) {
                        for (int i = 0; i < joCities.length; i++) {
                            try {
                                if (shiStr.equals(joCities[i].getString("name"))) {
                                    jaHospitals = joCities[i].getJSONArray("hospitals");
                                    joHospitals = new JSONObject[jaHospitals.length()];
                                    nameHospitals = new String[joHospitals.length];
                                    for (int j = 0; j < jaHospitals.length(); j++) {
                                        joHospitals[j] = jaHospitals.getJSONObject(j);
                                        nameHospitals[j] = joHospitals[j].getString("name");
                                    }

                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block

                                e.printStackTrace();
                            }
                        }
                    }
                    shi.setOnTouchListener(new View.OnTouchListener() {
                        @Override
                        public boolean onTouch(View view, MotionEvent motionEvent) {

                            Log.i(TAG, "year touch ");
                            closeSoftKeyboard();
                            return false;
                        }
                    });
                    hospitalAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
                            nameHospitals) {
                        @Override
                        public View getDropDownView(int position, View convertView, ViewGroup parent) {
                            LayoutInflater inflater = (LayoutInflater) getContext()
                                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            View view = inflater.inflate(R.layout.spinner_item_layout, null);
                            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

                            label.setText(nameHospitals[position]);

                            return view;
                            //return super.getDropDownView(position, convertView, parent);
                        }
                    };

                    //?
                    hospitalAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
                    yy.setAdapter(hospitalAdapter);

                    yy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> yyparent, View yyview, int yyposition,
                                long yyid) {
                            // TODO Auto-generated method stub
                            yyStr = yyparent.getItemAtPosition(yyposition).toString();
                            if (yyStr.equals(nameHospitals[yyposition])) {
                                for (int i = 0; i < joHospitals.length; i++) {
                                    try {
                                        if (yyStr.equals(joHospitals[i].getString("name"))) {
                                            jaDepartments = joHospitals[i].getJSONArray("departments");
                                            joDepartments = new JSONObject[jaDepartments.length()];
                                            nameDepartments = new String[joDepartments.length];
                                            idDepartments = new int[joDepartments.length];
                                            for (int j = 0; j < jaDepartments.length(); j++) {
                                                joDepartments[j] = jaDepartments.getJSONObject(j);
                                                nameDepartments[j] = joDepartments[j].getString("name");
                                                idDepartments[j] = joDepartments[j].getInt("id");

                                            }

                                        }
                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block

                                        e.printStackTrace();
                                    }
                                }
                            }
                            yy.setOnTouchListener(new View.OnTouchListener() {
                                @Override
                                public boolean onTouch(View view, MotionEvent motionEvent) {

                                    Log.i(TAG, "year touch ");
                                    closeSoftKeyboard();
                                    return false;
                                }
                            });
                            //                                departmentAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, android.R.layout.simple_spinner_item, nameDepartments) {
                            //                                    @Override
                            //                                    public View getDropDownView(int position, View convertView, ViewGroup parent) {
                            //                                        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            //                                        View view = inflater.inflate(R.layout.spinner_item_layout,
                            //                                                null);
                            //                                        TextView label = (TextView) view
                            //                                                .findViewById(R.id.spinner_item_label);
                            //
                            //                                        label.setText(nameDepartments[position]);
                            //
                            //
                            //                                        return view;
                            //                                        //return super.getDropDownView(position, convertView, parent);
                            //                                    }
                            //                                };
                            //
                            //                                ?
                            //                                departmentAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
                            //                                ks.setAdapter(departmentAdapter);
                            //                                try {
                            //                                    ks.setSelection(joDoc.getInt("departmentId") - 1, true);
                            //                                } catch (JSONException e) {
                            //                                    e.printStackTrace();
                            //                                }
                            //                                ks.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            //
                            //                                    @Override
                            //                                    public void onItemSelected(
                            //                                            AdapterView<?> ksparent, View ksview,
                            //                                            int ksposition, long ksid) {
                            //                                        // TODO Auto-generated method stub
                            //                                        ksStr = ksparent.getItemAtPosition(ksposition).toString();
                            //                                        if (ksStr.equals(nameDepartments[ksposition])) {
                            //                                            try {
                            //                                                idDepartmentInt = idDepartments[ksposition];
                            //                                                joDepartmentType = joDepartments[ksposition].getJSONObject("departmentType");
                            //                                                departmentTypeTv.setText(joDepartmentType.getString("name"));
                            //                                            } catch (JSONException e) {
                            //                                                // TODO Auto-generated catch block
                            //
                            //                                                e.printStackTrace();
                            //                                            }
                            //                                        }
                            //                                    }
                            //
                            //
                            //                                    @Override
                            //                                    public void onNothingSelected(
                            //                                            AdapterView<?> arg0) {
                            //                                        // TODO Auto-generated method stub
                            //
                            //                                    }
                            //                                });
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> arg0) {
                            // TODO Auto-generated method stub

                        }
                    });
                    //                        ks.setOnTouchListener(new View.OnTouchListener() {
                    //                            @Override
                    //                            public boolean onTouch(View view, MotionEvent motionEvent) {
                    //
                    //                                Log.i(TAG, "year touch ");
                    //                                closeSoftKeyboard();
                    //                                return false;
                    //                            }
                    //                        });
                }

                @Override
                public void onNothingSelected(AdapterView<?> arg0) {
                    // TODO Auto-generated method stub

                }
            });

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });
    year.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            yearStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    month.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            monthStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    day.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            dayStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    sex.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            sexStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });

    for (int i = 0; i < sexList.size(); i++) {
        if (sexList.get(i).equals(sexStr)) {
            sex.setSelection(i, true);
            break;
        }
    }
    for (int i = 0; i < yearList.size(); i++) {
        if (yearList.get(i).equals(yearStr)) {
            year.setSelection(i, true);
            break;
        }
    }
    for (int i = 0; i < monthList.size(); i++) {
        if (monthList.get(i).equals(monthStr)) {
            month.setSelection(i, true);
            break;
        }
    }
    for (int i = 0; i < dayList.size(); i++) {
        if (dayList.get(i).equals(dayStr)) {
            day.setSelection(i, true);
            break;
        }
    }
    photoBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            picKind = 0;
            //                startActivityForResult(new Intent(ModifyInfoActivity.this, SelectPictureActivity.class), REQUEST_PICK);

            Intent intent = new Intent(ModifyInfoActivity.this, SelectPictureActivity.class);
            intent.putExtra("from", "modify");
            startActivityForResult(intent, REQUEST_PICK);
            //RegisterActivity.this.finish();
        }
    });

    signBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            picKind = 1;
            //                startActivityForResult(new Intent(ModifyInfoActivity.this, SelectPictureActivity.class), REQUEST_PICK);
            Intent intent = new Intent(ModifyInfoActivity.this, SelectPictureActivity.class);
            intent.putExtra("from", "modify");
            startActivityForResult(intent, REQUEST_PICK);
        }
    });

    regBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            modify();

        }
    });

}