Example usage for android.widget AdapterView getId

List of usage examples for android.widget AdapterView getId

Introduction

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

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:eu.trentorise.smartcampus.jp.ItineraryChoicesFragment.java

@Override
public void onStart() {
    super.onStart();

    getSherlockActivity().getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

    TextView dateTextView = (TextView) getView().findViewById(R.id.choices_date);
    // Date dateDate = Utils.sjDateString2date(singleJourney.getDate());
    // dateTextView.setText(new SimpleDateFormat(Config.FORMAT_DATE_UI,
    // Locale.US).format(dateDate));
    dateTextView.setText(Utils.serverDate2UIDate(singleJourney.getDate()));

    TextView timeTextView = (TextView) getView().findViewById(R.id.choices_time);
    // Date timeDate =
    // Utils.sjTimeString2date(singleJourney.getDepartureTime());
    // timeTextView.setText(new SimpleDateFormat(Config.FORMAT_TIME_UI,
    // Locale.ITALY).format(timeDate));
    timeTextView.setText(Utils.serverTime2UITime(singleJourney.getDepartureTime()));

    TextView fromTextView = (TextView) getView().findViewById(R.id.choices_from);
    fromTextView.setText(singleJourney.getFrom().getName());

    TextView toTextView = (TextView) getView().findViewById(R.id.choices_to);
    toTextView.setText(singleJourney.getTo().getName());

    View itinerariesPromotedView = getView().findViewById(R.id.choices_promoted_layout);
    ListView itinerariesPromotedList = (ListView) getView().findViewById(R.id.choices_promoted_listView);
    ListView itinerariesList = (ListView) getView().findViewById(R.id.choices_listView);
    noItemsView = (LinearLayout) getView().findViewById(R.id.no_items_label);
    noItemsView.setVisibility(View.GONE);

    if (itinerariesPromotedAdapter == null) {
        itinerariesPromotedAdapter = new ItinerariesListAdapter(getSherlockActivity(),
                R.layout.itinerarychoices_row);
    }/*  ww  w. ja  va  2  s.co  m*/
    itinerariesPromotedList.setAdapter(itinerariesPromotedAdapter);

    if (itinerariesAdapter == null) {
        itinerariesAdapter = new ItinerariesListAdapter(getSherlockActivity(), R.layout.itinerarychoices_row);
    }
    itinerariesList.setAdapter(itinerariesAdapter);

    if (!mLoaded) {
        SCAsyncTask<SingleJourney, Void, List<Itinerary>> task = new SCAsyncTask<SingleJourney, Void, List<Itinerary>>(
                getSherlockActivity(), new PlanNewJourneyProcessor(getSherlockActivity(), itinerariesList,
                        itinerariesAdapter, itinerariesPromotedView, itinerariesPromotedAdapter, noItemsView));
        task.execute(singleJourney);
        mLoaded = true;
    }

    AdapterView.OnItemClickListener onClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ArrayAdapter<Itinerary> adapter = null;
            if (parent.getId() == R.id.choices_promoted_listView) {
                adapter = itinerariesPromotedAdapter;
            } else if ((parent.getId() == R.id.choices_listView)) {
                adapter = itinerariesAdapter;
            }

            if (adapter != null) {
                // ActionBar actionBar =
                // getSherlockActivity().getSupportActionBar();
                //
                // // navigation mode tabs
                // if (actionBar.getNavigationMode() !=
                // ActionBar.NAVIGATION_MODE_TABS) {
                // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
                // }
                //
                // actionBar.removeAllTabs();
                //
                // // Itinerary steps
                // ActionBar.Tab tab = actionBar.newTab();
                // tab.setText(R.string.tab_itinerary);
                // tab.setTabListener(new
                // TabListener<ItineraryFragment>(getSherlockActivity(),
                // "itinerary",
                // ItineraryFragment.class, null));
                // Bundle bundle = new Bundle();
                // bundle.putSerializable(ItineraryFragment.JOURNEY,
                // singleJourney);
                // bundle.putSerializable(ItineraryFragment.ITINERARY,
                // adapter.getItem(position));
                // tab.setTag(bundle);
                // actionBar.addTab(tab);
                //
                // // Itinerary map
                // tab = actionBar.newTab();
                // tab.setText(R.string.tab_map);
                // tab.setTabListener(new
                // TabListener<ItineraryFragment>(getSherlockActivity(),
                // "map",
                // ItineraryFragment.class, null));
                // bundle = new Bundle();
                // bundle.putSerializable(ItineraryFragment.JOURNEY,
                // singleJourney);
                // bundle.putSerializable(ItineraryFragment.ITINERARY,
                // adapter.getItem(position));
                // tab.setTag(bundle);
                // actionBar.addTab(tab);
                //
                // actionBar.selectTab(actionBar.getTabAt(0));

                FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager()
                        .beginTransaction();
                Fragment fragment = ItineraryFragment.newInstance(singleJourney, adapter.getItem(position));
                fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                fragmentTransaction.replace(Config.mainlayout, fragment,
                        ItineraryChoicesFragment.this.getTag());
                fragmentTransaction.addToBackStack(fragment.getTag());
                fragmentTransaction.commit();
            }
        }
    };

    itinerariesPromotedList.setOnItemClickListener(onClickListener);
    itinerariesList.setOnItemClickListener(onClickListener);

    itinerariesPromotedAdapter.notifyDataSetChanged();
    itinerariesAdapter.notifyDataSetChanged();

    if (itinerariesPromotedAdapter.isEmpty()) {
        itinerariesPromotedView.setVisibility(View.GONE);
    } else {
        itinerariesPromotedView.setVisibility(View.VISIBLE);
    }

    if (itinerariesAdapter.isEmpty()) {
        itinerariesList.setVisibility(View.GONE);
    } else {
        itinerariesList.setVisibility(View.VISIBLE);
    }
}

From source file:com.mstoyanov.music_lessons.ScheduleFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.lessons_list:
        Cursor cursor = (Cursor) parent.getItemAtPosition(position);
        int studentId = cursor.getInt(cursor.getColumnIndex("studentID"));
        lessonId = cursor.getInt(cursor.getColumnIndex("_id"));
        String firstName = cursor.getString(cursor.getColumnIndex("firstName"));
        String lastName = cursor.getString(cursor.getColumnIndex("lastName"));
        if (dualPane) {
            selectionArgs_delete[0] = String.valueOf(lessonId);

            lessonsList.setItemChecked(position, true);
            selectedLesson = position;/*from  ww w. ja va  2s. c  o m*/

            selectionArgs_actions[0] = String.valueOf(studentId);

            firstNameLabel.setText("First Name");
            firstNameTextView.setText(firstName);
            lastNameLabel.setText("Last Name");
            lastNameTextView.setText(lastName);

            getLoaderManager().restartLoader(ACTIONS_LOADER, null, this);
        } else {
            Intent intent = new Intent(getActivity(), LessonDetailsActivity.class);
            intent.putExtra("LESSON_ID", lessonId);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
        break;
    case R.id.actions_list:
        Actions action = actions.get(position);
        switch (action.getType()) {
        case Actions.ACTION_CALL:
            Uri callUri = Uri.parse("tel:" + action.getData());
            Intent intent = new Intent(Intent.ACTION_CALL, callUri);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        case Actions.ACTION_EMAIL:
            intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { action.getData() });
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        case Actions.ACTION_SMS:
            Uri smsUri = Uri.parse("sms:" + action.getData());
            intent = new Intent(Intent.ACTION_VIEW, smsUri);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        default:
            throw new IllegalArgumentException("Invalid action type: " + action.getType());
        }
        break;
    default:
        throw new IllegalArgumentException("Invalid parentId: " + parent.getId());
    }
}

From source file:joshuatee.wx.MiscFragment.java

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

    switch (parent.getId()) {
    case R.id.spinner2:
        if (spinner2.getSelectedItemPosition() != 0) {
            intent = new Intent(getActivity(), ImageShowActivity.class);
            intent.putExtra(ImageShowActivity.URL,
                    new String[] { qpf_urls[spinner2.getSelectedItemPosition() - 1],
                            qpf_label[spinner2.getSelectedItemPosition()] + " QPF" });
            startActivity(intent);// ww w .j a  v a2s.  co  m
        }
        spinner2.setSelection(0);
        break;
    case R.id.spinner1:
        int spinner1_pos = spinner1.getSelectedItemPosition();
        String type = "basicwx";
        if (spinner1_pos > 5) {
            type = "medr";
        }

        //medr
        if (spinner1_pos == 1) {
            intent = new Intent(getActivity(), ImageShowActivity.class);
            intent.putExtra(ImageShowActivity.URL, new String[] { "http://www.hpc.ncep.noaa.gov/noaa/noaa.gif",
                    fmap_label[spinner1_pos] + " Forecast" });
            startActivity(intent);
        } else if (spinner1_pos != 0) {
            intent = new Intent(getActivity(), ImageShowActivity.class);
            intent.putExtra(ImageShowActivity.URL,
                    new String[] {
                            "http://www.hpc.ncep.noaa.gov/" + type + "/"
                                    + fmap_codes[spinner1.getSelectedItemPosition()] + ".gif",
                            fmap_label[spinner1_pos] + " Forecast" });
            startActivity(intent);
        }
        spinner1.setSelection(0);
        break;

    }

}

From source file:com.mifos.mifosxdroid.online.createnewclient.CreateNewClientFragment.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.sp_offices:
        officeId = clientOffices.get(position).getId();
        createNewClientPresenter.loadStaffInOffices(officeId);
        break;//from ww  w.j  a v a  2  s  .co  m
    case R.id.sp_gender:
        genderId = clientsTemplate.getGenderOptions().get(position).getId();
        break;
    case R.id.sp_client_type:
        clientTypeId = clientsTemplate.getClientTypeOptions().get(position).getId();
        break;
    case R.id.sp_staff:
        staffId = clientStaff.get(position).getId();
        break;
    case R.id.sp_client_classification:
        clientClassificationId = clientsTemplate.getClientClassificationOptions().get(position).getId();
        break;
    }
}

From source file:org.dvbviewer.controller.ui.fragments.StreamConfig.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    Editor editor = prefs.edit();// ww  w  .  j  av  a  2  s.  c  om
    switch (parent.getId()) {
    case R.id.qualitySpinner:
        editor.putInt(DVBViewerPreferences.KEY_STREAM_QUALITY, position);
        break;
    case R.id.aspectSpinner:
        editor.putInt(DVBViewerPreferences.KEY_STREAM_ASPECT_RATIO, position);
        break;
    case R.id.ffmpegSpinner:
        editor.putInt(DVBViewerPreferences.KEY_STREAM_FFMPEG_PRESET, position);
        break;
    case R.id.widthSpinner:
        editor.putInt(DVBViewerPreferences.KEY_STREAM_MAX_WIDTH, position);
        break;
    case R.id.heightSpinner:
        editor.putInt(DVBViewerPreferences.KEY_STREAM_MAX_HEIGHT, position);
        break;

    default:
        break;
    }
    editor.commit();
}

From source file:li.barter.fragments.ChatDetailsFragment.java

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

    if (parent.getId() == R.id.list_chats) {

        final boolean resendOnClick = (Boolean) view.getTag(R.string.tag_resend_on_click);

        if (resendOnClick) {
            final Cursor cursor = (Cursor) mChatDetailAdapter.getItem(position);

            final int dbRowId = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
            final String message = cursor.getString(cursor.getColumnIndex(DatabaseColumns.MESSAGE));

            if (sendChatMessage(message)) {
                //Delete the older message from the table
                DBInterface.deleteAsync(QueryTokens.DELETE_CHAT_MESSAGE, getTaskTag(), null,
                        TableChatMessages.NAME, mMessageSelection, new String[] { String.valueOf(dbRowId) },
                        true, this);
            } else {
                showCrouton(R.string.error_not_connected_to_chat_service, AlertStyle.ERROR);
            }//from  w ww.  jav a 2  s.c  o m
        }
    }
}

From source file:com.android.medisolv.RegistrationActivity.java

@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

    if (adapterView.getId() == R.id.spinner1) {
        item = adapterView.getItemAtPosition(i).toString();
    } else if (adapterView.getId() == R.id.genderSpinner) {
        gender = adapterView.getItemAtPosition(i).toString();
    }//  w  w w .  java 2 s  .  c om
    if (adapterView.getId() == R.id.regTypeSpinner) {
        if (i > 0) {
            /*code to un hide the specialisation and license edit text*/
            registrationType = adapterView.getItemAtPosition(i).toString();
            specialisation = (EditText) findViewById(R.id.reg_spl);
            license = (EditText) findViewById(R.id.reg_license);
            if (registrationType.equals(new String("Doctor"))) {
                doctorFlag = true;
                specialisation.setVisibility(View.VISIBLE);
                license.setVisibility(View.VISIBLE);
            } else {
                doctorFlag = false;
                specialisation.setVisibility(View.INVISIBLE);
                license.setVisibility(View.INVISIBLE);
            }

        } else {
            /*code to popup message to select the registration type when it is not selected*/
            // Toast.makeText(getApplicationContext(), "Please select the Registration type", Toast.LENGTH_LONG).show();
        }
    }
}

From source file:com.example.android.apprestrictionenforcer.AppRestrictionEnforcerFragment.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.rank: {
        saveRank(getActivity(), (String) parent.getAdapter().getItem(position));
        break;// w ww  .j av  a  2  s  .  c o m
    }
    }
}

From source file:com.h6ah4i.android.example.openslmediaplayer.app.contents.VisualizerFragment.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.spinner_visualizer_scaling_mode:
        postAppEvent(VisualizerReqEvents.SET_SCALING_MODE, position, 0);
        break;/*from ww w .ja v a  2 s  . co  m*/
    }
}

From source file:li.barter.fragments.SelectPreferredLocationFragment.java

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

    if (parent.getId() == R.id.list_locations) {

        final Venue venue = (Venue) mSelectLocationAdapter.getItem(position);
        setUserPreferredLocation(venue.name, venue.address, venue.latitude, venue.longitude, venue.city,
                venue.state, venue.country, venue.foursquareId);
    }/*www.  jav  a 2s. co  m*/
}