Example usage for android.widget AdapterView getItemAtPosition

List of usage examples for android.widget AdapterView getItemAtPosition

Introduction

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

Prototype

public Object getItemAtPosition(int position) 

Source Link

Document

Gets the data associated with the specified position in the list.

Usage

From source file:sysnetlab.android.sdc.ui.fragments.ExperimentSensorSetupFragment.java

private void updateAudioSensorSetupView() {
    Button btnSetSamplingRate = (Button) mView.findViewById(R.id.button_sensor_setup_set_parameter);
    btnSetSamplingRate.setVisibility(View.GONE);

    TextView tv = (TextView) mView.findViewById(R.id.textview_sensor_setup_sensor_name);
    tv.setText(mSensor.getName());/*  ww w.  j av  a 2  s  .co  m*/

    mListView = (ListView) mView.findViewById(R.id.listview_audio_sensor_setup);

    UserInterfaceUtils.fillSensorProperties(getActivity(), mListView, mSensor);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
            SensorProperty property = (SensorProperty) listView.getItemAtPosition(position);

            if (property.getName().equals(getActivity().getResources().getString(R.string.text_audio_source))) {
                showAudioSensorDialog(mAudioRecordParameters, ((AudioSensor) mSensor).getAudioRecordParameter(),
                        AudioSensorSetupDialogFragment.SELECT_SOURCE);
            } else if (property.getName()
                    .equals(getActivity().getResources().getString(R.string.text_audio_channel_in))) {
                showAudioSensorDialog(mAudioRecordParameters, ((AudioSensor) mSensor).getAudioRecordParameter(),
                        AudioSensorSetupDialogFragment.SELECT_CHANNEL_IN);
            } else if (property.getName()
                    .equals(getActivity().getResources().getString(R.string.text_audio_encoding))) {
                showAudioSensorDialog(mAudioRecordParameters, ((AudioSensor) mSensor).getAudioRecordParameter(),
                        AudioSensorSetupDialogFragment.SELECT_ENCODING);
            } else if (property.getName()
                    .equals(getActivity().getResources().getString(R.string.text_audio_sampling_rate))) {
                showAudioSensorDialog(mAudioRecordParameters, ((AudioSensor) mSensor).getAudioRecordParameter(),
                        AudioSensorSetupDialogFragment.SELECT_SAMPLING_RATE);
            } else if (property.getName()
                    .equals(getActivity().getResources().getString(R.string.text_audio_min_buffer_size))) {
                showAudioSensorDialog(mAudioRecordParameters, ((AudioSensor) mSensor).getAudioRecordParameter(),
                        AudioSensorSetupDialogFragment.SELECT_MIN_BUFFER_SIZE);
            }
        }
    });
}

From source file:p1.nd.khan.jubair.mohammadd.popularmovies.MainActivityFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (null != mCallback) {
        Cursor cursor = (Cursor) parent.getItemAtPosition(position);
        if (null != cursor) {
            mCallback.onMoviePosterSelected(cursor.getInt(cursor.getColumnIndex(MovieEntry.C_MOVIE_ID)),
                    cursor.getString(cursor.getColumnIndex(MovieEntry.C_POSTER_PATH)), getView(), position,
                    mSortOrder);/*from  w  ww  .ja  v a 2  s  .c  o m*/
        }
        mPosition = position;
    }
}

From source file:de.uni_koblenz_landau.apow.ObsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.obs_list_fragment, container, false);

    // Create UI references.
    mListView = (ListView) view.findViewById(R.id.obs_list_fragment_listview);
    mListView.setEmptyView(view.findViewById(android.R.id.empty));
    mListView.getEmptyView().setVisibility(ListView.GONE);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override/*from   w w  w .  j a  va2 s  . c o  m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ListViewItem item = (ListViewItem) parent.getItemAtPosition(position);
            Intent intent = new Intent(getActivity(), ObsDetailActivity.class);
            intent.putExtra(ObsDetailFragment.ARG_OBS_ID, (int) id);
            intent.putExtra(ObsDetailFragment.ARG_ENCOUNTER_ID, mEncounterID);
            intent.putExtra(ObsDetailFragment.ARG_TITLE, item.getField1());
            getActivity().startActivity(intent);
        }
    });

    // Restore UI from saved instance or load data.
    if (savedInstanceState != null) {
        mDeleteDialog = (DeleteDialogFragment) getFragmentManager().findFragmentByTag(DELETE_DIALOG_ID);
        if (mDeleteDialog != null) {
            mDeleteDialog.setListener(this);
        }
        mTitle = savedInstanceState.getString(ARG_TITLE);
        getActivity().setTitle(mTitle);
        mObs = savedInstanceState.getParcelableArrayList(ARG_OBS);
        ObsAdapter adapter = new ObsAdapter(this.getActivity(), mObs);
        mListView.setAdapter(adapter);
    } else {
        mTitle = getArguments().getString(ARG_TITLE);
        loadObs(mTitle);
    }

    return view;
}

From source file:com.jsw.MngProductDatabase.Fragments.ListProduct_Fragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mList = getListView();//from   w  w w  .j ava  2 s .  c o  m
    setListAdapter(mAdapter);

    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int i, long l) {
            Bundle potatoe = new Bundle();
            potatoe.putParcelable(PRODUCT_KEY, (Product) parent.getItemAtPosition(i));
            mCallback.showManageProduct(potatoe);
        }
    });

    mList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            mItemParent = adapterView;
            mItemPos = i;

            popup = new PopupMenu(getContext(), view);
            popup.setGravity(Gravity.END);
            popup.getMenuInflater().inflate(R.menu.delete_menu, popup.getMenu());

            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    p = (Product) mItemParent.getItemAtPosition(mItemPos);
                    mCallback.showDeletePopUp(p);
                    return true;
                }
            });
            popup.show();
            return true;
        }
    });

    mFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCallback.showManageProduct(null);
        }
    });
    mPresenter.getAllProducts();
}

From source file:es.usc.citius.servando.calendula.activities.PatientsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_patients);
    setupStatusBar(getResources().getColor(R.color.dark_grey_home));
    setupToolbar("Pacientes", getResources().getColor(R.color.dark_grey_home));
    subscribeToEvents();/* w w  w.  j  av  a2  s . c om*/

    //patients = DB.patients().findAll();
    fab = (FloatingActionButton) findViewById(R.id.add_button);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(PatientsActivity.this, PatientDetailActivity.class);
            startActivity(intent);
        }
    });

    gridView = (GridView) findViewById(R.id.grid);
    adapter = new PatientAdapter(this);
    gridView.setAdapter(adapter);
    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Patient p = (Patient) parent.getItemAtPosition(position);
            if (!p.isDefault())
                showRemovePatientDialog(p);
            else
                showRemoveDefaultPatientMsgDialog(p);
            return true;
        }
    });
}

From source file:com.burntout.burntout.SendReportActivity.java

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

}

From source file:ca.ualberta.cmput301.t03.trading.TradeOfferHistoryFragment.java

/**
 * Sets up adapters for view elements representing trades
 *//*  w w  w .  java  2s.com*/
private void setupListView(Context context) {

    if (context == null) {
        //we probably got killed, so just return
        return;
    }

    adapter = new TradesAdapter<>(context, model);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Trade selected = (Trade) (parent.getItemAtPosition(position));
            final UUID tradeUUID = selected.getTradeUUID();

            if (PrimaryUser.getInstance().getUsername().equals(selected.getOwner().getUsername())) {
                AsyncTask worker = new AsyncTask() {
                    @Override
                    protected Object doInBackground(Object[] params) {
                        try {
                            selected.setHasBeenSeen(true);
                            selected.commitChanges();

                        } catch (ServiceNotAvailableException e) {
                            // do nothing here
                        }
                        return null;
                    }
                };
                worker.execute();
            }
            Intent intent = new Intent(getContext(), TradeOfferReviewActivity.class);
            intent.putExtra("TRADE_UUID", tradeUUID);
            startActivity(intent);
        }
    });
}

From source file:org.qeo.deviceregistration.ui.SettingsRealmFragment.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    mSelectedRealmName = parent.getItemAtPosition(position).toString();

    if (mSelectedRealmName.equals(getString(R.string.add_realm_item))) {
        // selected "add realm"
        ((SettingsActivity) getActivity()).addRealmDialog();

    } else {/*  www  .  ja  va  2s  .co  m*/
        // selected existing realm
        mSelectedRealmId = RealmCache.getRealmId(mSelectedRealmName);
        if (mSelectedRealmId == 0) {
            LOG.warning("Can't find realm " + mSelectedRealmName + " in the cache");
            return;
        }
    }
}

From source file:tinygsn.gui.android.ActivityPullData.java

public void renderVSList() {
    spinner_vsName = (Spinner) findViewById(R.id.spinner_pull_vsname);
    List<String> list = new ArrayList<String>();

    for (String vs : vsNameList) {
        list.add(vs);/*from  www  .j  a v  a  2s . co  m*/
    }

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_vsName.setAdapter(dataAdapter);

    spinner_vsName.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            Toast.makeText(parent.getContext(),
                    "The VS \"" + parent.getItemAtPosition(pos).toString() + "\" is selected.",
                    Toast.LENGTH_SHORT).show();
        }

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

From source file:com.dena.app.usage.watcher.fragment.WatchFragment.java

public void onItemClick(AdapterView adapterview, View view, int i, long l) {
    final WatchItem item = (WatchItem) adapterview.getItemAtPosition(i);
    final Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage(item.getPackageName());
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(item.getAppName());
    List<String> list = new ArrayList<>();
    list.add(getString(R.string.set_usage_limit));
    list.add(getString(R.string.reset_usage_limit));
    list.add(getString(R.string.hide_this_app));
    if (null != intent) {
        list.add(getString(R.string.launch_this_app));
    }/*from   w  w  w  .  j  a v  a 2 s  .c om*/
    builder.setItems(list.toArray(new String[0]), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialoginterface, int j) {
            switch (j) {
            case 0:
                showSetTimerDialog(item);
                break;
            case 1:
                mDB.setTimerInfo(item.getPackageName(), 0);
                mDB.setTimerWarning(item.getPackageName(), 0);
                mDB.setTimerFinish(item.getPackageName(), 0);
                onRefresh();
                break;
            case 2:
                (new UnwatchManager(getActivity())).addUnwatch(item.getPackageName());
                onRefresh();
                break;
            case 3:
                if (null != intent) {
                    startActivity(intent);
                }
                break;
            }
        }
    });
    AlertDialog alertdialog = builder.create();
    alertdialog.setCancelable(true);
    alertdialog.setCanceledOnTouchOutside(true);
    alertdialog.show();
}