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.example.office365sample.MainActivity.java

protected void doLogin() {
    try {//from  www.  j a  va 2  s.  c o m
        mAuthContext = new AuthenticationContext(this, Constants.AUTHORITY_URL, false);
        mAuthContext.acquireToken(this, Constants.RESOURCE_ID, Constants.CLIENT_ID, Constants.REDIRECT_URL,
                Constants.USER_HINT, new AuthenticationCallback<AuthenticationResult>() {

                    @Override
                    public void onSuccess(final AuthenticationResult result) {
                        if (result != null && !TextUtils.isEmpty(result.getAccessToken())) {

                            Configuration.setAuthenticator(new IAuthenticator() {
                                @Override
                                public void prepareRequest(HttpUriRequest request) {
                                    request.addHeader("Authorization", "Bearer " + result.getAccessToken());
                                }

                                @Override
                                public void prepareClient(HttpClient client) throws NetworkException {
                                }

                            });
                            Log.i(TAG, "Received access token, ready to work.");
                            MainActivity.this.readMessages();
                        }
                    }

                    @Override
                    public void onError(Exception exc) {
                        Log.i(TAG, exc.getMessage());
                        listViewMessages.setAdapter(
                                new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1,
                                        new String[] { "Error during authentication: ", exc.getMessage() }));
                    }
                });
    } catch (Exception exc) {
        Log.i(TAG, exc.getMessage());
        listViewMessages
                .setAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1,
                        new String[] { "Error during authentication:", exc.getMessage() }));
    }
}

From source file:com.fuzz.android.limelight.model.ChapterTransition.java

public static void getDrawerPosition() {
    LayoutInflater inflater = LimeLight.getActivity().getLayoutInflater();
    View drawerView = inflater.inflate(R.layout.choose_drawer_item, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(LimeLight.getActivity());
    builder.setTitle(R.string.choose_drawer_item);
    builder.setView(drawerView);/*from  w w  w .  java2s  . c  om*/

    final Spinner positionSpinner = (Spinner) drawerView.findViewById(R.id.positionSpinner);

    ArrayList<String> items = new ArrayList<String>();
    for (int i = 0; i < LimeLight.getDrawerList().getAdapter().getCount(); i++) {
        items.add(i + "");
    }

    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(LimeLight.getActivity(),
            android.R.layout.simple_spinner_dropdown_item, items);

    positionSpinner.setAdapter(spinnerArrayAdapter);

    positionSpinner.setSelection(mDrawerItemPosition);

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDrawerItemPosition = Integer.valueOf(positionSpinner.getSelectedItem().toString());
        }
    });

    builder.setNegativeButton(R.string.cancel, null);

    builder.create();
    builder.show();
}

From source file:com.zira.registration.BackgroundCheckActivity.java

private void setAdapterForLicenceState() {
    statesArrayList = SingleTon.getInstance().getSelectedStates();

    if (statesArrayList.size() > 0) {

        //gettingLicenceState=mProfileInfoModel.getDrivinglicensestate();
        gettingLicenceState = mProfileInfoModel.getDrivinglicensestateID();
        /*if(gettingLicenceState.equals("0"))
        {/*from w ww.  j  av a  2 s.com*/
           //gettingLicenceState=prefs3.getString("DrivinglicensestateID", "");
           //System.err.println("DrivinglicensestateID="+prefs3.getString("DrivinglicensestateID", ""));
           }*/
    }
    int i = 0;
    for (State state : statesArrayList) {
        //String stateName=state.getStateName();
        String stateName = state.getStateId();
        //Log.e("stateID=", stateName);
        if (gettingLicenceState.equals(stateName)) {
            gettingLicenceStatePosition = i;
        }
        i++;
    }

    ArrayAdapter<State> dataAdapter = new ArrayAdapter<State>(this, R.layout.spinner_list, statesArrayList);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    licenceStateSpinner.setAdapter(dataAdapter);
    licenceStateSpinner.setSelection(gettingLicenceStatePosition);
}

From source file:fm.libre.droid.LibreDroid.java

/** Called when the activity is first created. */
@Override/*from  w w w.  ja v  a2s  .c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    libreServiceConn = new LibreServiceConnection();
    bindService(new Intent(this, LibreService.class), libreServiceConn, Context.BIND_AUTO_CREATE);

    this.registerReceiver(new MediaButtonReceiver(), new IntentFilter(Intent.ACTION_MEDIA_BUTTON));
    this.registerReceiver(new UIUpdateReceiver(), new IntentFilter("LibreDroidNewSong"));
    setContentView(R.layout.main);

    // Load settings
    final SharedPreferences settings = getSharedPreferences("LibreDroid", MODE_PRIVATE);
    username = settings.getString("Username", "");
    password = settings.getString("Password", "");

    final EditText usernameEntry = (EditText) findViewById(R.id.usernameEntry);
    final EditText passwordEntry = (EditText) findViewById(R.id.passwordEntry);
    usernameEntry.setText(username);
    passwordEntry.setText(password);

    final Button loginButton = (Button) findViewById(R.id.loginButton);
    loginButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Editor editor = settings.edit();
            editor.putString("Username", usernameEntry.getText().toString());
            editor.putString("Password", passwordEntry.getText().toString());
            editor.commit();

            LibreDroid.this.login();
        }
    });

    stations = new ArrayList<String>();
    try {
        BufferedReader stationReader = new BufferedReader(
                new InputStreamReader(openFileInput("libredroid-custom-stations.conf")));
        String station;
        while ((station = stationReader.readLine()) != null) {
            stations.add(station);
        }
        stationReader.close();
    } catch (IOException ex) {
        Log.d("libredroid", ex.getMessage());
    }
    // Add default stations if empty
    if (stations.isEmpty()) {
        String radioButtons[] = { "Folk", "Rock", "Metal", "Classical", "Pop", "Punk", "Jazz", "Blues", "Rap",
                "Ambient", "Add A Custom Station..." };
        stations.addAll(Arrays.asList(radioButtons));
    }
    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, stations));

    Button tagStation = (Button) findViewById(R.id.tagStationButton);
    tagStation.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.nextPage();
        }
    });

    Button loveStation = (Button) findViewById(R.id.loveStationButton);
    loveStation.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.libreServiceConn.service.tuneStation("user", username + "/loved");
            LibreDroid.this.nextPage();
            LibreDroid.this.nextPage();
            LibreDroid.this.nextPage();
        }
    });

    Button communityLoveStation = (Button) findViewById(R.id.communityStationButton);
    communityLoveStation.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.libreServiceConn.service.tuneStation("community", "loved");
            LibreDroid.this.nextPage();
            LibreDroid.this.nextPage();
            LibreDroid.this.nextPage();
        }
    });

    final ImageButton nextButton = (ImageButton) findViewById(R.id.nextButton);
    nextButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.libreServiceConn.service.next();
        }
    });
    final ImageButton prevButton = (ImageButton) findViewById(R.id.prevButton);
    prevButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.libreServiceConn.service.prev();
        }
    });
    final ImageButton playPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
    playPauseButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.togglePause();
        }
    });
    final ImageButton saveButton = (ImageButton) findViewById(R.id.saveButton);
    saveButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.save();
        }
    });
    final ImageButton loveButton = (ImageButton) findViewById(R.id.loveButton);
    loveButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.libreServiceConn.service.love();
        }
    });
    final ImageButton banButton = (ImageButton) findViewById(R.id.banButton);
    banButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.libreServiceConn.service.ban();
        }
    });
    final Button addStationButton = (Button) findViewById(R.id.addStationButton);
    addStationButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LibreDroid.this.addStation();
        }
    });
}

From source file:com.mifos.mifosxdroid.dialogfragments.LoanAccountDisbursement.java

private void inflatePaymentTypeSpinner() {
    App.apiManager.getLoanTemplate(loanAccountNumber, new Callback<Response>() {
        @Override/*from  w w w .ja va2s.  c om*/
        public void success(Response result, Response response) {
            final ArrayList<PaymentTypeOptions> paymentOption = new ArrayList<PaymentTypeOptions>();
            final ArrayList<String> paymentNames = new ArrayList<String>();
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            String line;
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("paymentTypeOptions")) {
                    JSONArray paymentOptions = obj.getJSONArray("paymentTypeOptions");
                    for (int i = 0; i < paymentOptions.length(); i++) {
                        JSONObject paymentObject = paymentOptions.getJSONObject(i);
                        PaymentTypeOptions payment = new PaymentTypeOptions();
                        payment.setId(paymentObject.optInt("id"));
                        payment.setName(paymentObject.optString("name"));
                        paymentOption.add(payment);
                        paymentNames.add(paymentObject.optString("name"));
                        paymentNameIdHashMap.put(payment.getName(), payment.getId());
                    }
                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, "", e);
            }
            ArrayAdapter<String> paymentAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, paymentNames);
            paymentAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_payment_type.setAdapter(paymentAdapter);
            sp_payment_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    paymentTypeId = paymentNameIdHashMap.get(paymentNames.get(i));
                    Log.d("paymentId " + paymentNames.get(i), String.valueOf(paymentTypeId));
                    if (paymentTypeId != -1) {

                    } else {

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

                    }

                }

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

                }
            });

        }

        @Override
        public void failure(RetrofitError retrofitError) {

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

}

From source file:com.bellman.bible.android.view.activity.base.DocumentSelectionBase.java

private void initialiseView() {
    // prepare action mode
    listActionModeHelper = new ListActionModeHelper(getListView(), actionModeMenuId);
    // trigger action mode on long press
    getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override//w  ww  . ja va  2 s .  c  om
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            return listActionModeHelper.startActionMode(DocumentSelectionBase.this, position);
        }
    });

    languageList = new ArrayList<Language>();
    displayedDocuments = new ArrayList<Book>();

    ArrayAdapter<Book> listArrayAdapter = new DocumentItemAdapter(this, LIST_ITEM_TYPE, displayedDocuments,
            isInstallStatusIconsShown, this);
    setListAdapter(listArrayAdapter);

    //prepare the documentType spinner
    documentTypeSpinner = (Spinner) findViewById(R.id.documentTypeSpinner);
    setInitialDocumentType();
    documentTypeSpinner.setSelection(selectedDocumentFilterNo);
    documentTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            selectedDocumentFilterNo = position;
            DocumentSelectionBase.this.filterDocuments();
        }

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

    //prepare the language spinner
    {
        langSpinner = (Spinner) findViewById(R.id.languageSpinner);
        langSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                selectedLanguageNo = position;
                lastSelectedLanguage = languageList.get(selectedLanguageNo);
                DocumentSelectionBase.this.filterDocuments();
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });
        langArrayAdapter = new ArrayAdapter<Language>(this, android.R.layout.simple_spinner_item, languageList);
        langArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        langSpinner.setAdapter(langArrayAdapter);
    }
}

From source file:com.mifos.mifosxdroid.dialogfragments.ChargeDialogFragment.java

private void inflateChargesSpinner() {
    showProgress(true);//from w w  w . j  ava 2  s  .  c om
    App.apiManager.getAllChargesV2(clientId, new Callback<Response>() {

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

            Log.d(LOG_TAG, "Charges Loaded Successfully");

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

                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, e.getMessage());
            }
            final ArrayAdapter<String> chargesAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, chargesNames);
            chargesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_charge_name.setAdapter(chargesAdapter);
            sp_charge_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    Id = chargeNameIdHashMap.get(chargesNames.get(i));
                    Log.d("chargesoptionss" + chargesNames.get(i), String.valueOf(Id));
                    if (Id != -1) {

                    } else {

                        Toast.makeText(getActivity(), getString(R.string.error_select_charge),
                                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:oss.ridendivideapp.TakeRideActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

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

    /* Create a DBAdapter object */
    tkr_datasource = new DBAdapter(this);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        str_usrid = extras.getString("usrid");
    }// w  w w .  j  a  v a 2 s .  c o  m

    buttonSearch = (Button) findViewById(R.id.btn_tr_search);
    buttonCancel = (Button) findViewById(R.id.btn_tr_cancel);

    /* Create a PlacesAutoCompleteAdapter object for the From field */
    tkr_frm_acView = (AutoCompleteTextView) findViewById(R.id.txt_tr_from);
    tkr_frm_adapter = new PlacesAutoCompleteAdapter(this, R.layout.frm_item_list);
    tkr_frm_acView.setAdapter(tkr_frm_adapter);
    tkr_frm_acView.setOnItemClickListener(this);

    /* Create a PlacesAutoCompleteAdapter object for the To field */
    tkr_to_acView = (AutoCompleteTextView) findViewById(R.id.txt_tr_to);
    tkr_to_adapter = new PlacesAutoCompleteAdapter(this, R.layout.to_item_list);
    tkr_to_acView.setAdapter(tkr_to_adapter);
    tkr_to_acView.setOnItemClickListener(this);

    /* Create a spinner for the Seats field */
    sp_seats = (Spinner) findViewById(R.id.spn_tr_seats);
    ArrayAdapter<String> seats_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            str_seats);
    sp_seats.setAdapter(seats_adapter);

    /* Create a spinner for the Flexible hrs field */
    sp_hrs = (Spinner) findViewById(R.id.spn_tr_flexhrs);
    ArrayAdapter<String> hrs_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            str_hrs);
    sp_hrs.setAdapter(hrs_adapter);

    /* Date picker pops up a dialog with the given date format 
    and allows user to pick a date for a ride */
    datePicker = (Button) findViewById(R.id.btn_tr_datepicker);
    datePicker.setText(dateFormatter.format(dateTime.getTime()));
    datePicker.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showDialog(DIALOG_DATE);
        }
    });

    /* Time picker pops up a dialog with the given time format 
    and allows user to pick a time for a ride */
    timePicker = (Button) findViewById(R.id.btn_tr_timepicker);
    timePicker.setText(timeFormatter.format(dateTime.getTime()));
    timePicker.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showDialog(DIALOG_TIME);
        }
    });

    buttonSearch.setOnClickListener(buttonSearchOnClickListener);
    buttonCancel.setOnClickListener(buttonCancelOnClickListener);
    sp_seats.setOnItemSelectedListener(spinnerseatsOnItemSelectedListener);
    sp_hrs.setOnItemSelectedListener(spinnerhrsOnItemSelectedListener);
}

From source file:com.sourcey.materiallogindemo.MainActivity.java

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

    // Permission StrictMode
    if (Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }// ww w  .j a va 2  s. com

    Bundle extras = getIntent().getExtras();
    // ?? null
    if (extras != null) {
        user_id = extras.getString("user_id");
        name = extras.getString("name");
        image = extras.getString("image");
    }

    txtStart = (AutoCompleteTextView) findViewById(R.id.txtStart);
    txtEnd = (AutoCompleteTextView) findViewById(R.id.txtEnd);
    txtAppoint = (AutoCompleteTextView) findViewById(R.id.txtAppoint);
    txtTime = (EditText) findViewById(R.id.txtTime);
    txtLicensePlate = (EditText) findViewById(R.id.txtLicensePlate);
    btnImageProfile = (ImageButton) findViewById(R.id.btnImageProfile);
    txtName = (TextView) findViewById(R.id.txtName);

    radioGroup = (RadioGroup) findViewById(R.id.radio);

    badge = (TextView) findViewById(R.id.badge);

    final Button btnSave = (Button) findViewById(R.id.btnSave);
    final Button btnCancel = (Button) findViewById(R.id.btnCancel);
    //final Button btnPost = (Button) findViewById(R.id.btnPost);
    final Button btnFeed = (Button) findViewById(R.id.btnFeed);
    final Button btnSearch = (Button) findViewById(R.id.btnSearch);
    final Button btnNotification = (Button) findViewById(R.id.btnNotification);
    final Button btnLogout = (Button) findViewById(R.id.btnLogout);
    final Button btnTime = (Button) findViewById(R.id.btnTime);
    final Button btnComment = (Button) findViewById(R.id.btnComment);
    // get the current time
    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);

    mHour = c.get(Calendar.HOUR);
    mMinute = c.get(Calendar.MINUTE);

    String url = getString(R.string.url) + "notification.php";
    notifications = master.GetCountNotification(user_id, url);
    if (notifications > 0) {
        badge.setVisibility(View.VISIBLE);
        badge.setText(String.valueOf(notifications));
    } else {
        badge.setVisibility(View.GONE);
    }

    // display the current time
    updateCurrentTime();
    LoadItems();
    //Create adapter
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, item);
    txtStart.setThreshold(1);
    //Set adapter to AutoCompleteTextView
    txtStart.setAdapter(adapter);
    txtStart.setOnItemSelectedListener(this);
    txtStart.setOnItemClickListener(this);

    //Set adapter to AutoCompleteTextView
    txtEnd.setAdapter(adapter);
    txtEnd.setOnItemSelectedListener(this);
    txtEnd.setOnItemClickListener(this);
    //Create adapter

    //Set adapter to AutoCompleteTextView
    txtAppoint.setAdapter(adapter);
    txtAppoint.setOnItemSelectedListener(this);
    txtAppoint.setOnItemClickListener(this);

    txtName.setText(name);
    String photo_url_str = getString(R.string.url_image)
            + (("".equals(image.trim()) || image == null) ? "no.png" : image.trim());
    URL newurl = null;
    try {
        newurl = new URL(photo_url_str);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    Bitmap b = null;
    try {
        b = BitmapFactory.decodeStream(newurl.openConnection().getInputStream());
    } catch (IOException e) {
        e.printStackTrace();
    }
    btnImageProfile.setImageBitmap(Bitmap.createScaledBitmap(b, 80, 80, false));

    btnSearch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogMap();
        }
    });

    btnTime.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(TIME_DIALOG_ID);
        }
    });
    btnSave.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            int selectedId = radioGroup.getCheckedRadioButtonId();

            // find the radiobutton by returned id
            type = ((RadioButton) findViewById(radioGroup.getCheckedRadioButtonId())).getText().toString();
            if ("".equals(type)) {
                type = "CAR";
            } else {
                type = "NOCAR";
            }
            /* Toast.makeText(getBaseContext(),
                type, Toast.LENGTH_SHORT).show();*/

            start = txtStart.getText().toString();
            end = txtEnd.getText().toString();
            meeting_point = txtAppoint.getText().toString();
            map_datetime = datePoint.trim();
            license_plate = txtLicensePlate.getText().toString();

            if ("".equals(start) || "".equals(end) || "".equals(meeting_point) || "".equals(map_datetime)
                    || "".equals(license_plate) || "".equals(txtTime.getText().toString().trim())) {
                MessageDialog("???");
            } else {
                String url = getString(R.string.url) + "save.php";
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("user_id", user_id));
                params.add(new BasicNameValuePair("start", start));
                params.add(new BasicNameValuePair("end", end));
                params.add(new BasicNameValuePair("meeting_point", meeting_point));
                params.add(new BasicNameValuePair("map_datetime", map_datetime));
                params.add(new BasicNameValuePair("license_plate", license_plate));
                params.add(new BasicNameValuePair("type", type));

                String resultServer = getHttpPost(url, params);

                JSONObject c;
                try {
                    c = new JSONObject(resultServer);
                    String status = c.getString("status");
                    MessageDialog(status);
                    if ("?".equals(status)) {
                        ClearData();
                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    MessageDialog(e.getMessage());
                }
            }
        }
    });

    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ClearData();
        }
    });

    /*        btnPost.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       *//* Intent i = new Intent(getBaseContext(), PostItemActivity.class);
          i.putExtra("user_id", user_id);
          startActivity(i);*//*
                              // get selected radio button from radioGroup
                                      
                              }
                              });*/

    btnFeed.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            /*  if(!start.getText().toString().equals("") &&!end.getText().toString().equals("")&&
                !point.getText().toString().equals("")&&!time.getText().toString().equals("")&&!license.getText().toString().equals("")) {
            Intent newActivity = new Intent(MainActivity.this, commit.class);
            startActivity(newActivity);
              }*/
            Intent i = new Intent(getBaseContext(), PostItemActivity.class);
            i.putExtra("user_id", user_id);
            i.putExtra("name", name);
            i.putExtra("image", image);
            startActivity(i);
        }
    });
    btnNotification.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getBaseContext(), NotificationActivity.class);
            i.putExtra("user_id", user_id);
            i.putExtra("name", name);
            i.putExtra("image", image);
            startActivity(i);
        }
    });
    btnLogout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getBaseContext(), LoginActivity.class);
            startActivity(i);
        }
    });
    btnComment.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getBaseContext(), CommentActivity.class);
            i.putExtra("user_id", user_id);
            i.putExtra("name", name);
            i.putExtra("image", image);
            startActivity(i);
        }
    });
    /*      final Button btn5 = (Button) findViewById(R.id.button3);
          btn5.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent(MainActivity.this, LoginActivity.class);
        startActivity(intent);
    }
          });*/

    //RadioGroup car = (RadioGroup) this.findViewById ( R.id.textView18 );

    // car.check(R.id.radioButton);
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    //client2 = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

From source file:org.maikelwever.droidpile.SendMailActivity.java

public void setAdapters(ArrayList<AutocompleteContact> contacts) {
    this.contacts = contacts;
    adapter = new ArrayAdapter<AutocompleteContact>(this, android.R.layout.simple_list_item_1, contacts);

    addressView.setAdapter(adapter);/* w  ww  . ja  va 2 s  . c o m*/
    ccView.setAdapter(adapter);
    //bccView.setAdapter(adapter);
}