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) 

Source Link

Document

Constructor

Usage

From source file:auribises.com.visitorbook.Activites.AdminEntryActivity.java

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

    ButterKnife.inject(this);

    preferences = getSharedPreferences(Util.PREFS_NAME, MODE_PRIVATE);
    editor = preferences.edit();/*ww w .  j ava  2  s  .  co m*/

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Please Wait..");
    progressDialog.setCancelable(false);

    adminentry = new Adminentry();

    adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter1.add("--Select IDProof--");
    adapter1.add("Aadhar Card");
    adapter1.add("License");
    adapter1.add("PAN Card");
    adapter1.add("Voter Card");

    spIDProof.setAdapter(adapter1);

    spIDProof.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                adminentry.setIDProof(adapter1.getItem(i));
            }
        }

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

        }
    });

    adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter2.add("--Vehicle Type--");
    adapter2.add("None");
    adapter2.add("Car");
    adapter2.add("Bike");
    adapter2.add("Activa");

    spVehicle.setAdapter(adapter2);

    spVehicle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                adminentry.setVehicle(adapter2.getItem(i));
            }
        }

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

        }
    });

    rbMale.setOnCheckedChangeListener(this);
    rbFemale.setOnCheckedChangeListener(this);

    resolver = getContentResolver();

    requestQueue = Volley.newRequestQueue(this);

    Intent rcv = getIntent();
    updateMode = rcv.hasExtra("keyAdminentry");

    if (updateMode) {
        rcvAdminentry = (Adminentry) rcv.getSerializableExtra("keyAdminentry");
        eTxtName.setText(rcvAdminentry.getName());
        eTxtPhone.setText(rcvAdminentry.getPhone());
        eTxtEmail.setText(rcvAdminentry.getEmail());
        eTxtAddress.setText(rcvAdminentry.getAddress());
        eTxtPurpose.setText(rcvAdminentry.getPurpose());
        eTxtDate.setText(rcvAdminentry.getDate());
        eTxtTime.setText(rcvAdminentry.getTime());
        eTxtAdmin.setText(rcvAdminentry.getAdmin());
        eTxtIDProofNumber.setText(rcvAdminentry.getIDProofnumber());
        eTxtVehicleNumber.setText(rcvAdminentry.getVehiclenumber());

        if (rcvAdminentry.getGender().equals("Male")) {
            rbMale.setChecked(true);
        } else {
            rbFemale.setChecked(true);
        }

        int q = 0;
        for (int i = 0; i < adapter1.getCount(); i++) {
            if (adapter1.getItem(i).equals(rcvAdminentry.getIDProof())) {
                Log.i("TEST2", adapter1.getItem(i) + " - " + rcvAdminentry.getIDProof());
                q = i;
                break;
            }
        }
        spIDProof.setSelection(q);

        int r = 0;
        for (int i = 0; i < adapter2.getCount(); i++) {
            if (adapter2.getItem(i).equals(rcvAdminentry.getVehicle())) {
                Log.i("TEST3", adapter2.getItem(i) + " - " + rcvAdminentry.getVehicle());
                r = i;
                break;
            }
        }
        spVehicle.setSelection(r);

        btnSubmit.setText("Update");
    }
}

From source file:auribises.com.visitorbook.Activites.VisitorEntryActivity.java

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

    ButterKnife.inject(this);

    preferences = getSharedPreferences(Util.PREFS_NAME, MODE_PRIVATE);
    editor = preferences.edit();/*www.  j  a va2 s .c  o  m*/

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Please Wait..");
    progressDialog.setCancelable(false);

    visitorentry = new Visitorentry();

    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter.add("--Select Branch--");
    adapter.add("Applied Sciences");
    adapter.add("Civil Engineering");
    adapter.add("Electrical Engineering");
    adapter.add("Mechanical Engineering");
    adapter.add("Electroncis & Communication Engineering");
    adapter.add("Computer Science & Engineering");
    adapter.add("Information Technology");
    adapter.add("Production Engineering");
    adapter.add("Business Administration");
    adapter.add("Computer Applications");
    ;

    spBranch.setAdapter(adapter);

    spBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                visitorentry.setBranch(adapter.getItem(i));
            }
        }

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

        }
    });

    adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter1.add("--Select IDProof--");
    adapter1.add("Aadhar Card");
    adapter1.add("License");
    adapter1.add("PAN Card");
    adapter1.add("Voter Card");

    spIDProof.setAdapter(adapter1);

    spIDProof.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                visitorentry.setIDProof(adapter1.getItem(i));
            }
        }

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

        }
    });

    adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter2.add("--Vehicle Type--");
    adapter2.add("Car");
    adapter2.add("Bike");
    adapter2.add("Activa");
    adapter2.add("Auto");
    adapter2.add("Bus");

    spVehicle.setAdapter(adapter2);

    spVehicle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                visitorentry.setVehicle(adapter2.getItem(i));
            }
        }

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

        }
    });

    rbMale.setOnCheckedChangeListener(this);
    rbFemale.setOnCheckedChangeListener(this);

    resolver = getContentResolver();

    requestQueue = Volley.newRequestQueue(this);

    Intent rcv = getIntent();
    updateMode = rcv.hasExtra("keyVisitorentry");

    if (updateMode) {
        rcvVisitorentry = (Visitorentry) rcv.getSerializableExtra("keyVisitorentry");
        eTxtName.setText(rcvVisitorentry.getName());
        eTxtPhone.setText(rcvVisitorentry.getPhone());
        eTxtEmail.setText(rcvVisitorentry.getEmail());
        eTxtAddress.setText(rcvVisitorentry.getAddress());
        eTxtPurpose.setText(rcvVisitorentry.getPurpose());
        eTxtDate.setText(rcvVisitorentry.getDate());
        eTxtTime.setText(rcvVisitorentry.getTime());
        eTxtTeacher.setText(rcvVisitorentry.getTeacher());
        eTxtIDProofNumber.setText(rcvVisitorentry.getIDProofnumber());
        eTxtVehicleNumber.setText(rcvVisitorentry.getVehiclenumber());

        if (rcvVisitorentry.getGender().equals("Male")) {
            rbMale.setChecked(true);
        } else {
            rbFemale.setChecked(true);
        }

        Log.i("TEST", adapter + " - " + rcvVisitorentry.getBranch() + " - " + rcvVisitorentry.getIDProof()
                + " - " + rcvVisitorentry.getVehicle());

        int p = 0;
        for (int i = 0; i < adapter.getCount(); i++) {
            if (adapter.getItem(i).equals(rcvVisitorentry.getBranch())) {
                Log.i("TEST1", adapter.getItem(i) + " - " + rcvVisitorentry.getBranch());
                p = i;
                break;
            }
        }
        spBranch.setSelection(p);

        int q = 0;
        for (int i = 0; i < adapter1.getCount(); i++) {
            if (adapter1.getItem(i).equals(rcvVisitorentry.getIDProof())) {
                Log.i("TEST2", adapter1.getItem(i) + " - " + rcvVisitorentry.getIDProof());
                q = i;
                break;
            }
        }
        spIDProof.setSelection(q);

        int r = 0;
        for (int i = 0; i < adapter2.getCount(); i++) {
            if (adapter2.getItem(i).equals(rcvVisitorentry.getVehicle())) {
                Log.i("TEST3", adapter2.getItem(i) + " - " + rcvVisitorentry.getVehicle());
                r = i;
                break;
            }
        }
        spVehicle.setSelection(r);

        btnSubmit.setText("Update");
    }
}

From source file:com.glabs.homegenie.widgets.MediaServerDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    _view = getActivity().getLayoutInflater().inflate(R.layout.widget_control_mediaserver, null);
    builder.setView(_view);/* ww  w.  j ava  2s .  c o  m*/

    builder.setMessage(_module.getDisplayName())
            .setPositiveButton("Play", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // Play to...
                    playMediaTo();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // User cancelled the dialog
                }
            });

    mAdapter = new MediaFilesAdapter(_view.getContext(), R.layout.widget_control_mediaserver_item,
            new ArrayList<MediaEntry>());
    final ListView lv = (ListView) _view.findViewById(R.id.filesList);
    lv.setAdapter(mAdapter);
    //
    if (navigationStack.size() == 0) {
        navigationStack.add("0");
    }
    //
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            MediaEntry clicked = mAdapter.getItem(i);
            mAdapter.setSelectedIndex(i);
            _selectedMedia = null;
            //
            if (clicked.Class.indexOf("object.container") == 0) {
                // browse to folder
                _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
                if (clicked.Title.equals(PARENT_FOLDER)) {
                    navigationStack.removeLast();
                } else {
                    navigationStack.add(clicked.Id);
                }
                browseMediaFolder(lv);
            } else {
                // set current media file
                _selectedMedia = clicked;
                _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
            }
        }
    });
    //

    Control.getGroupModules("", new Control.GetGroupModulesCallback() {
        @Override
        public void groupModulesUpdated(ArrayList<Module> modules) {
            ArrayAdapter<CharSequence> playtoitems = new ArrayAdapter<CharSequence>(_view.getContext(),
                    android.R.layout.simple_spinner_item);
            //
            playtoitems.add("This device");
            //
            for (int m = 0; m < modules.size(); m++) {
                Module module = modules.get(m);
                ModuleParameter devtype = module.getParameter("UPnP.StandardDeviceType");
                if (devtype != null && devtype.Value.equals("MediaRenderer")) {
                    renderers.add(module);
                    playtoitems.add(Control.getUpnpDisplayName(module));
                }
            }
            //
            // Media Renderer Spinner Select
            Spinner playto = (Spinner) _view.findViewById(R.id.playto);
            playto.setAdapter(playtoitems);
            playto.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    _selectedMediaRender = null;
                    if (i > 0) {
                        _selectedMediaRender = renderers.get(i - 1);
                    }
                }

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

                }
            });

        }
    });
    //
    browseMediaFolder(lv);

    // Create the AlertDialog object and return it
    _dialog = builder.create();
    _dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
        }
    });
    return _dialog;
}

From source file:com.nordicsemi.nrfUARTv2.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*from w w  w . j  a v a2  s .  com*/
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBtAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    messageListView = (ListView) findViewById(R.id.listMessage);
    listAdapter = new ArrayAdapter<String>(this, R.layout.message_detail);
    messageListView.setAdapter(listAdapter);
    messageListView.setDivider(null);
    btnConnectDisconnect = (Button) findViewById(R.id.btn_select);
    btnConnectRight = (Button) findViewById(R.id.button);
    btnSend = (Button) findViewById(R.id.sendButton);
    edtMessage = (EditText) findViewById(R.id.sendText);
    service_init();

    // Handler Disconnect & Connect button
    btnConnectDisconnect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //should not be here, only for debug
            UploadData();
            //                if (!mBtAdapter.isEnabled()) {
            //                    Log.i(TAG, "onClick - BT not enabled yet");
            //                    Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            //                    startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
            //                }
            //                else {
            //                    if (btnConnectDisconnect.getText().equals("Connect Left")){
            //
            //                        //Connect button pressed, open DeviceListActivity class, with popup windows that scan for devices
            //
            //                        Intent newIntent = new Intent(MainActivity.this, DeviceListActivity.class);
            //                        startActivityForResult(newIntent, REQUEST_SELECT_DEVICE);
            //                    } else {
            //                        //Disconnect button pressed
            //                        if (mDevice!=null)
            //                        {
            //                            mService.disconnect();
            //
            //                        }
            //                        if (mDevice2!=null)
            //                        {
            //                            mService2.disconnect();
            //
            //                        }
            //                        mCollecting = false;
            //                        UploadData();
            //                    }
            //                }
        }
    });

    btnConnectRight.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mBtAdapter.isEnabled()) {
                Log.i(TAG, "onClick - BT not enabled yet");
                Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
            } else {
                if (btnConnectRight.getText().equals("Connect Right")) {

                    //Connect button pressed, open DeviceListActivity class, with popup windows that scan for devices

                    Intent newIntent = new Intent(MainActivity.this, DeviceListActivity.class);
                    startActivityForResult(newIntent, REQUEST_SELECT_DEVICE2);
                } else {
                    //Disconnect button pressed
                    if (mDevice2 != null) {
                        mService2.disconnect();

                    }
                }
            }
        }
    });

    // Handler Send button  
    btnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText editText = (EditText) findViewById(R.id.sendText);
            String message = editText.getText().toString();
            byte[] value;
            try {
                //send data to service
                value = message.getBytes("UTF-8");
                mService.writeRXCharacteristic(value);
                //Update the log with time stamp
                String currentDateTimeString = DateFormat.getTimeInstance().format(new Date());
                listAdapter.add("[" + currentDateTimeString + "] TX: " + message);
                messageListView.smoothScrollToPosition(listAdapter.getCount() - 1);
                edtMessage.setText("");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    });

    // Set initial UI state

}

From source file:com.clevertrail.mobile.findtrail.Activity_FindTrail_ByLocation.java

private void createProximityComboBox() {
    m_cbFindTrailByLocationProximity = (Spinner) findViewById(R.id.cbFindTrailProximity);
    m_adapterForSpinner = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
    m_adapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    m_adapterForSpinner.add(getString(R.string.proximityspinner_5miles));
    m_adapterForSpinner.add(getString(R.string.proximityspinner_10miles));
    m_adapterForSpinner.add(getString(R.string.proximityspinner_25miles));
    m_adapterForSpinner.add(getString(R.string.proximityspinner_50miles));
    m_adapterForSpinner.add(getString(R.string.proximityspinner_100miles));

    m_cbFindTrailByLocationProximity.setAdapter(m_adapterForSpinner);
    // by default make it 25 miles
    m_cbFindTrailByLocationProximity.setSelection(2);
}

From source file:at.general.solutions.android.ical.activity.ICalSynchronizeActivity.java

/** Called when the activity is first created. */
@Override/*ww  w.  j  a v a  2s . c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button syncBtn = (Button) findViewById(R.id.connectToServer);
    eventListAdapter = new ArrayAdapter<ICalEvent>(this, android.R.layout.simple_list_item_1);
    parsedEvents = new ArrayList<ICalEvent>();

    ((ListView) findViewById(R.id.list)).setAdapter(eventListAdapter);

    syncBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.e(LOG_TAG, "Starting event processing");
            showDialog(DOWNLOAD_PROGRESS_DIALOG);

            /*UpdateCalendarThread uct = new UpdateCalendarThread(ICalSynchronizeActivity.this, "nu", null);
            uct.deleteCalendar(3);
            uct.deleteCalendar(4);
            uct.deleteCalendar(5);*/
        }
    });

    Button removeBtn = (Button) findViewById(R.id.removeCalendar);
    removeBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            new AlertDialog.Builder(ICalSynchronizeActivity.this).setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle(getString(R.string.confirmRemoval))
                    .setMessage(getString(R.string.confirmRemovalText))
                    .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            showDialog(REMOVE_CALENDAR_PROGRESS_DIALOG);
                        }

                    }).setNegativeButton(getString(R.string.no), null).show();
        }
    });

    if (!checkPreferences()) {
        Toast.makeText(this, getString(R.string.preferencesIncomplete), Toast.LENGTH_LONG).show();
    }
}

From source file:com.nextgis.maplibui.formcontrol.DoubleCombobox.java

@Override
public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor,
        SharedPreferences preferences) throws JSONException {
    mSubCombobox = new Spinner(getContext());
    JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
    mFieldName = attributes.getString(JSON_FIELD_LEVEL1_KEY);
    mSubFieldName = attributes.getString(JSON_FIELD_LEVEL2_KEY);
    mIsShowLast = ControlHelper.isSaveLastValue(attributes);
    setEnabled(ControlHelper.isEnabled(fields, mFieldName));

    String lastValue = null;// w w w  . j  av  a2s  . com
    String subLastValue = null;
    if (ControlHelper.hasKey(savedState, mFieldName) && ControlHelper.hasKey(savedState, mSubFieldName)) {
        lastValue = savedState.getString(ControlHelper.getSavedStateKey(mFieldName));
        subLastValue = savedState.getString(ControlHelper.getSavedStateKey(mSubFieldName));
    } else if (null != featureCursor) {
        int column = featureCursor.getColumnIndex(mFieldName);
        int subColumn = featureCursor.getColumnIndex(mSubFieldName);
        if (column >= 0)
            lastValue = featureCursor.getString(column);
        if (subColumn >= 0)
            subLastValue = featureCursor.getString(subColumn);
    } else if (mIsShowLast) {
        lastValue = preferences.getString(mFieldName, null);
        subLastValue = preferences.getString(mSubFieldName, null);
    }

    JSONArray values = attributes.optJSONArray(JSON_VALUES_KEY);
    int defaultPosition = 0;
    int lastValuePosition = -1;
    int subLastValuePosition = -1;
    mAliasValueMap = new HashMap<>();
    mSubAliasValueMaps = new HashMap<>();
    mAliasSubListMap = new HashMap<>();

    final ArrayAdapter<String> comboboxAdapter = new ArrayAdapter<>(getContext(),
            R.layout.formtemplate_double_spinner);
    setAdapter(comboboxAdapter);

    if (values != null) {
        for (int j = 0; j < values.length(); j++) {
            JSONObject keyValue = values.getJSONObject(j);
            String value = keyValue.getString(JSON_VALUE_NAME_KEY);
            String valueAlias = keyValue.getString(JSON_VALUE_ALIAS_KEY);

            Map<String, String> subAliasValueMap = new HashMap<>();
            AliasList subAliasList = new AliasList();

            mAliasValueMap.put(valueAlias, value);
            mSubAliasValueMaps.put(valueAlias, subAliasValueMap);
            mAliasSubListMap.put(valueAlias, subAliasList);
            comboboxAdapter.add(valueAlias);

            if (keyValue.has(JSON_DEFAULT_KEY) && keyValue.getBoolean(JSON_DEFAULT_KEY))
                defaultPosition = j;

            if (null != lastValue && lastValue.equals(value)) // if modify data
                lastValuePosition = j;

            JSONArray subValues = keyValue.getJSONArray(JSON_VALUES_KEY);
            for (int k = 0; k < subValues.length(); k++) {
                JSONObject subKeyValue = subValues.getJSONObject(k);
                String subValue = subKeyValue.getString(JSON_VALUE_NAME_KEY);
                String subValueAlias = subKeyValue.getString(JSON_VALUE_ALIAS_KEY);

                subAliasValueMap.put(subValueAlias, subValue);
                subAliasList.aliasList.add(subValueAlias);

                if (subKeyValue.has(JSON_DEFAULT_KEY) && subKeyValue.getBoolean(JSON_DEFAULT_KEY))
                    subAliasList.defaultPosition = k;

                if (null != subLastValue && subLastValue.equals(subValue)) { // if modify data
                    lastValuePosition = j;
                    subLastValuePosition = k;
                }
            }
        }
    }

    setSelection(lastValuePosition >= 0 ? lastValuePosition : defaultPosition);
    final int subLastValuePositionFinal = subLastValuePosition;

    // The drop down view
    comboboxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    float minHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14,
            getResources().getDisplayMetrics());
    setPadding(0, (int) minHeight, 0, (int) minHeight);
    mSubCombobox.setPadding(0, (int) minHeight, 0, (int) minHeight);

    setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String selectedValueAlias = comboboxAdapter.getItem(position);
            AliasList subAliasList = mAliasSubListMap.get(selectedValueAlias);

            ArrayAdapter<String> subComboboxAdapter = new ArrayAdapter<>(view.getContext(),
                    R.layout.formtemplate_double_spinner, subAliasList.aliasList);
            subComboboxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            mSubCombobox.setAdapter(subComboboxAdapter);
            mSubCombobox.setSelection(mFirstShow && subLastValuePositionFinal >= 0 ? subLastValuePositionFinal
                    : subAliasList.defaultPosition);

            if (mFirstShow) {
                mFirstShow = false;
            }
        }

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

From source file:net.eledge.android.europeana.gui.activity.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    NewBlogNotification.cancel(this);

    PreferenceManager.setDefaultValues(this, R.xml.settings, false);

    searchController.suggestionPageSize = getResources().getInteger(R.integer.home_suggestions_pagesize);
    isLandscape = getResources().getBoolean(R.bool.home_support_landscape);

    mSuggestionsAdaptor = new SuggestionAdapter(this, new ArrayList<Item>());
    mGridViewSuggestions.setAdapter(mSuggestionsAdaptor);
    mGridViewSuggestions.setOnItemClickListener(this);

    mEditTextQuery.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from   ww  w.ja  va 2  s.  c  om*/
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                performSearch(v.getText().toString());
                return true;
            }
            return false;
        }
    });
    mEditTextQuery.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 2) {
                if (mGridViewSuggestions.isShown()) {
                    mSuggestionsAdaptor.clear();
                    mSuggestionsAdaptor.notifyDataSetChanged();
                }
                searchController.suggestions(HomeActivity.this, s.toString());
            } else {
                onTaskFinished(null);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // ignore
        }

        @Override
        public void afterTextChanged(Editable s) {
            // ignore
        }
    });

    mProfilesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item);
    mSpinnerProfiles.setAdapter(mProfilesAdapter);

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (mBlogFragment == null) {
        mBlogFragment = new HomeBlogFragment();
    }
    fragmentTransaction.replace(R.id.activity_home_fragment_blog, mBlogFragment);
    fragmentTransaction.commit();
}

From source file:app.park.com.bluetooth.BluetoothFragment.java

/**
 * Set up the UI and background operations for chat.
 *//*from   ww w  .  j  a v a2 s . c o  m*/
public void setupBT() {
    Log.d(TAG, "setupBT()");

    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message);

    mDiscoverableButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Ensure this device is discoverable by others
            ensureDiscoverable();
        }
    });

    mConnectButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Launch the DeviceListActivity to see devices and do scan
            Intent serverIntent = new Intent(getActivity(), DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE);
        }
    });

    // Initialize the BluetoothService to perform bluetooth connections
    mBTService = new BluetoothService(getActivity(), mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");
}

From source file:com.nextgis.mobile.map.RemoteTMSLayer.java

protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName,
        String layerUrl, int type, final RemoteTMSLayer layer) {
    final LinearLayout linearLayout = new LinearLayout(map.getContext());
    final EditText input = new EditText(map.getContext());
    input.setText(layerName);/* w  w w .j  av a2  s. co  m*/

    final EditText url = new EditText(map.getContext());
    url.setText(layerUrl);

    final TextView stLayerName = new TextView(map.getContext());
    stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":");

    final TextView stLayerUrl = new TextView(map.getContext());
    stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":");

    final TextView stLayerType = new TextView(map.getContext());
    stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":");

    final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(),
            android.R.layout.simple_spinner_item);
    final Spinner spinner = new Spinner(map.getContext());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    adapter.add(map.getContext().getString(R.string.tmstype_osm));
    adapter.add(map.getContext().getString(R.string.tmstype_normal));
    adapter.add(map.getContext().getString(R.string.tmstype_ngw));

    if (type == TMSTYPE_OSM) {
        spinner.setSelection(0);
    } else {
        spinner.setSelection(1);
    }

    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.addView(stLayerName);
    linearLayout.addView(input);
    linearLayout.addView(stLayerUrl);
    linearLayout.addView(url);
    linearLayout.addView(stLayerType);
    linearLayout.addView(spinner);

    new AlertDialog.Builder(map.getContext())
            .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties)
            //                                    .setMessage(message)
            .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    int tmsType = 0;
                    switch (spinner.getSelectedItemPosition()) {
                    case 0:
                    case 1:
                        tmsType = TMSTYPE_OSM;
                        break;
                    case 2:
                    case 3:
                        tmsType = TMSTYPE_NORMAL;
                        break;
                    }

                    if (bCreate) {
                        create(map, input.getText().toString(), url.getText().toString(), tmsType);
                    } else {
                        layer.setName(input.getText().toString());
                        layer.setTMSType(tmsType);
                        map.onLayerChanged(layer);
                    }
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing.
                    Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show();
                }
            }).show();
}