List of usage examples for android.widget AdapterView getAdapter
public abstract T getAdapter();
From source file:net.oremland.rss.reader.fragments.BaseListFragment.java
private OnItemClickListener getListViewClickListener() { return new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { list.setItemChecked(position, true); list.setSelection(position); TModel item = (TModel) parent.getAdapter().getItem(position); displayModel(item);/* w w w . ja v a 2s. c o m*/ } }; }
From source file:universe.constellation.orion.viewer.OrionFileManagerActivity.java
private void createFileView(ListFragment list) { ListView view = list.getListView(); view.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { File file = (File) parent.getItemAtPosition(position); if (file.isDirectory()) { File newFolder = ((FileChooser) parent.getAdapter()).changeFolder(file); updatePathTextView(newFolder.getAbsolutePath()); } else { if (showRecentsAndSavePath()) { SharedPreferences.Editor editor = prefs.edit(); editor.putString(Common.LAST_OPENED_DIRECTORY, file.getParentFile().getAbsolutePath()); editor.commit();/* www . j a va 2 s .co m*/ } openFile(file); } } }); list.setListAdapter(new FileChooser(this, getStartFolder(), getFileNameFilter())); }
From source file:nuclei.ui.view.media.PlayerControlsView.java
protected void onSpeedSelected(View v) { final String selected = ResourceProvider.getInstance().getSelectedSpeed(); final PopupMenu menu = new PopupMenu(v.getContext(), v, ResourceProvider.getInstance().getString(ResourceProvider.SPEED)); menu.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*w w w . ja v a 2 s. c om*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String text = (String) parent.getAdapter().getItem(position); if (text != null) { final float speed = ResourceProvider.getInstance().getSpeed(text); MediaProvider.getInstance().setAudioSpeed(speed); if (mMediaInterface != null) { mMediaInterface.setSpeed(speed); } } menu.dismiss(); menu.setOnItemClickListener(null); } }); menu.setAdapter(new ArrayAdapter<String>(v.getContext(), R.layout.cyto_view_dropdown_item_checkable, android.R.id.text1, ResourceProvider.getInstance().getSpeeds()) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView v = (TextView) view.findViewById(android.R.id.text1); CharSequence text = getItem(position); if (selected.equals(text)) { v.setTextColor(ViewUtil.getThemeAttrColor(v.getContext(), R.attr.colorAccent)); view.findViewById(R.id.checked).setVisibility(View.VISIBLE); } else { v.setTextColor(ViewUtil.getThemeAttrColor(v.getContext(), android.R.attr.textColorPrimary)); view.findViewById(R.id.checked).setVisibility(View.GONE); } return view; } }); menu.show(); }
From source file:org.mythdroid.activities.MDActivity.java
/** Create a dialog allowing user to choose default frontend */ private Dialog createFrontendDialog() { final AlertDialog d = new AlertDialog.Builder(ctx).setItems(new String[] {}, null) .setIcon(drawable.ic_menu_upload_you_tube).setTitle(R.string.chFe).create(); d.getListView().setOnItemClickListener(new OnItemClickListener() { @Override// w w w . j a va 2 s . c o m public void onItemClick(AdapterView<?> av, View v, int pos, long id) { onHere = false; String fe = (String) av.getAdapter().getItem(pos); Globals.curFe = fe; updateFrontendIndicator(); if (fe.equals(Messages.getString("MDActivity.0"))) // Here //$NON-NLS-1$ onHere = true; d.dismiss(); } }); return d; }
From source file:com.raza.betternts.activities.TabFragment2.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab_fragment_ignored, container, false); lvPosts = (ListView) view.findViewById(R.id.lv_posts_ignored); fillData();// w ww. j a v a 2s .c om { lvPosts.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, View view, final int position, long id) { /** * This is magic right here wow, thanks stackexchange */ final Cursor c = (Cursor) parent.getAdapter().getItem(position); String name = c.getString(c.getColumnIndex(DbSchema.COL_NAME)); //Show dialog for choices AlertDialog.Builder inputDialog = new AlertDialog.Builder(getContext()); inputDialog.setTitle(name).setItems(list, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { menuOption(c, which); } }); inputDialog.show(); } }); lvPosts.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { /** * This is magic right here wow, thanks stackexchange */ final Cursor c = (Cursor) parent.getAdapter().getItem(position); String name = c.getString(c.getColumnIndex(DbSchema.COL_NAME)); //Show dialog for choices AlertDialog.Builder inputDialog = new AlertDialog.Builder(getContext()); inputDialog.setTitle(name).setItems(list, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { menuOption(c, which); } }); inputDialog.show(); return true; } }); } return view; }
From source file:com.csipsimple.ui.help.Help.java
@Override public void onItemClick(AdapterView<?> av, View v, int position, long id) { Log.i(THIS_FILE, "Item clicked : " + id + " " + position); HelpArrayAdapter haa = (HelpArrayAdapter) av.getAdapter(); HelpEntry he = haa.getItem(position); DialogFragment newFragment;//from ww w .j ava2s. co m switch (he.choiceTag) { case FAQ: newFragment = Faq.newInstance(); newFragment.show(getSupportFragmentManager(), "faq"); break; case LEGALS: newFragment = Legal.newInstance(); newFragment.show(getSupportFragmentManager(), "issues"); break; case OPEN_ISSUES: Intent it = new Intent(Intent.ACTION_VIEW); it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); it.setData(Uri.parse("http://code.google.com/p/csipsimple/issues")); startActivity(it); break; case NIGHTLY: // We have to check for an update final NightlyUpdater nu = new NightlyUpdater(getActivity()); Thread t = new Thread() { public void run() { UpdaterPopupLauncher ru = nu.getUpdaterPopup(true); if (ru != null) { getActivity().runOnUiThread(ru); } }; }; t.start(); break; case SEND_LOGS: prefsWrapper.setPreferenceStringValue(SipConfigManager.LOG_LEVEL, "1"); try { startActivityForResult( CollectLogs.getLogReportIntent("<<<PLEASE ADD THE BUG DESCRIPTION HERE>>>", getActivity()), REQUEST_SEND_LOGS); } catch (Exception e) { Log.e(THIS_FILE, "Impossible to send logs...", e); } Log.setLogLevel(1); break; case START_LOGS: prefsWrapper.setPreferenceStringValue(SipConfigManager.LOG_LEVEL, "4"); Log.setLogLevel(4); Intent intent = new Intent(SipManager.ACTION_SIP_REQUEST_RESTART); getActivity().sendBroadcast(intent); dismiss(); break; default: break; } }
From source file:com.linkedin.android.eventsapp.EventFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final String eventNameArg = getArguments().getString(EXTRA_EVENT_NAME); final long eventDateArg = getArguments().getLong(EXTRA_EVENT_DATE); final String eventLocationArg = getArguments().getString(EXTRA_EVENT_LOCATION); int pictureIdArg = getArguments().getInt(EXTRA_PICTURE_ID); boolean isAttendingArg = getArguments().getBoolean(EXTRA_EVENT_ATTENDING); Person[] attendeesArg = (Person[]) getArguments().getParcelableArray(EXTRA_EVENT_ATTENDEES); SimpleDateFormat dateFormat = new SimpleDateFormat("E dd MMM yyyy 'at' hh:00 a"); final String dateString = dateFormat.format(new Date(eventDateArg)); View v = inflater.inflate(R.layout.layout_event_fragment, container, false); boolean accessTokenValid = LISessionManager.getInstance(getActivity()).getSession().isValid(); if (!accessTokenValid) { ViewStub linkedinLogin = (ViewStub) v.findViewById(R.id.connectWithLinkedInStub); linkedinLogin.inflate();//ww w . jav a 2 s. co m Button loginButton = (Button) v.findViewById(R.id.connectWithLinkedInButton); loginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i(TAG, "clicked login button"); LISessionManager.getInstance(getActivity()).init(getActivity(), Constants.scope, new AuthListener() { @Override public void onAuthSuccess() { Intent intent = new Intent(getActivity(), MainActivity.class); startActivity(intent); getActivity().finish(); } @Override public void onAuthError(LIAuthError error) { } }, false); } }); } TextView eventNameView = (TextView) v.findViewById(R.id.eventName); eventNameView.setText(eventNameArg); TextView eventLocationAndDateView = (TextView) v.findViewById(R.id.eventLocationAndDate); eventLocationAndDateView.setText(eventLocationArg + " " + dateString); TextView eventAttendeeCount = (TextView) v.findViewById(R.id.attendeeCount); eventAttendeeCount.setText("Other Attendees (" + attendeesArg.length + ")"); ImageView eventImageView = (ImageView) v.findViewById(R.id.eventImage); eventImageView.setImageResource(pictureIdArg); final Button attendButton = (Button) v.findViewById(R.id.attendButton); final Button declineButton = (Button) v.findViewById(R.id.declineButton); if (isAttendingArg) { attendButton.setText("Attending"); attendButton.setEnabled(false); declineButton.setText("Decline"); declineButton.setEnabled(true); } attendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((Button) v).setText("Attending"); v.setEnabled(false); declineButton.setText("Decline"); declineButton.setEnabled(true); if (LISessionManager.getInstance(getActivity()).getSession().isValid()) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setTitle("Share on LinkedIn?"); alertDialogBuilder.setCancelable(true) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { JSONObject shareObject = new JSONObject(); try { JSONObject visibilityCode = new JSONObject(); visibilityCode.put("code", "anyone"); shareObject.put("visibility", visibilityCode); shareObject.put("comment", "I am attending " + eventNameArg + " in " + eventLocationArg + " on " + dateString); } catch (JSONException e) { } APIHelper.getInstance(getActivity()).postRequest(getActivity(), Constants.shareBaseUrl, shareObject, new ApiListener() { @Override public void onApiSuccess(ApiResponse apiResponse) { Toast.makeText(getActivity(), "Your share was successful!", Toast.LENGTH_LONG); } @Override public void onApiError(LIApiError apiError) { Log.e(TAG, apiError.toString()); Toast.makeText(getActivity(), "Your share was unsuccessful. Try again later!", Toast.LENGTH_LONG); } }); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } } }); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((Button) v).setText("Declined"); v.setEnabled(false); attendButton.setText("Attend"); attendButton.setEnabled(true); } }); ListView attendeesListView = (ListView) v.findViewById(R.id.attendeesList); AttendeeAdapter adapter = new AttendeeAdapter(getActivity(), R.layout.attendee_list_item, attendeesArg, accessTokenValid); attendeesListView.setAdapter(adapter); attendeesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ArrayAdapter adapter = (ArrayAdapter) parent.getAdapter(); Person person = (Person) adapter.getItem(position); Intent intent = new Intent(getActivity(), ProfileActivity.class); Bundle extras = new Bundle(); extras.putParcelable("person", person); intent.putExtras(extras); startActivity(intent); } }); return v; }
From source file:com.learnNcode.mediachooser.fragment.VideoFragment.java
private void setAdapter() { int count = mCursor.getCount(); mDataColumnIndex = mCursor.getColumnIndex(MEDIA_DATA); //move position to first element mCursor.moveToFirst();// w w w . j a v a2s . co m mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < count; i++) { mCursor.moveToPosition(i); String url = mCursor.getString(mDataColumnIndex); mGalleryModelList.add(new MediaModel(url, false)); } mVideoAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, true); mVideoAdapter.videoFragment = this; mVideoGridView.setAdapter(mVideoAdapter); mVideoGridView.setOnScrollListener(this); mVideoGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT) && (!galleryModel.status)) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_reach_error), Toast.LENGTH_SHORT).show(); } else { // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); } else { mSelectedItems.remove(galleryModel.url.toString().trim()); } if (mCallback != null) { mCallback.onVideoSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } } }); }
From source file:com.nicolls.ablum.fragment.ImageFragment.java
private void setAdapter(Cursor imagecursor) { // Toast.makeText(getActivity(),pathList.size()+"###",Toast.LENGTH_SHORT).show(); if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); for (String path : pathList) { if (TextUtils.equals(path, galleryModel.url)) { galleryModel.status = true; mSelectedItems.add(galleryModel.url.toString()); break; }/*from w w w .j av a 2 s . c o m*/ } mGalleryModelList.add(galleryModel); } mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false); mImageGridView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "image/*"); startActivity(intent); return true; } }); mImageGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false); if (size != 0) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.file_size_exeeded) + " " + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " " + getActivity().getResources().getString(R.string.mb), Toast.LENGTH_SHORT).show(); return; } if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) { if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.file), Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.files), Toast.LENGTH_SHORT).show(); return; } } } // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); MediaChooserConstants.SELECTED_MEDIA_COUNT++; } else { mSelectedItems.remove(galleryModel.url.toString().trim()); MediaChooserConstants.SELECTED_MEDIA_COUNT--; } if (mCallback != null) { mCallback.onImageSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:it.sineo.android.tileMapEditor.HomeActivity.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent tiledMapActivity = new Intent(HomeActivity.this, TiledMapActivity.class); Cursor cur = (Cursor) parent.getAdapter().getItem(position); long mapid = cur.getLong(0); String json = cur.getString(2); tiledMapActivity.putExtra(C.EXTRA_MAP_JSON, json); tiledMapActivity.putExtra(C.EXTRA_MAP_ID, mapid); startActivityForResult(tiledMapActivity, C.REQ_CODE_EDIT_MAP); }