Search in sources :

Example 16 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class PlaceActivity3 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_1);
    textStatus = (TextView) findViewById(R.id.textStatus);
    listView = (ListView) findViewById(R.id.listView);
    gp = new GooglePlaceSearch(ApiKey);
    gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {

        public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
            textStatus.setText("Status : " + status);
            if (status.equals(GooglePlaceSearch.STATUS_OK)) {
                ArrayList<String> array = new ArrayList<String>();
                final ArrayList<String> array_photo = new ArrayList<String>();
                for (int i = 0; i < arr_data.size(); i++) {
                    array.add("Name : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME) + "\n" + "Address : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_ADDRESS) + "\n" + "Latitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LATITUDE) + "\n" + "Longitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LONGITUDE) + "\n" + "Phone Number : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHONENUMBER));
                    array_photo.add(arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHOTO));
                }
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(PlaceActivity3.this, R.layout.listview_text, array);
                listView.setAdapter(adapter);
                listView.setOnItemClickListener(new OnItemClickListener() {

                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                        Dialog dialog = new Dialog(PlaceActivity3.this);
                        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        dialog.setContentView(R.layout.dialog_photo);
                        dialog.setCancelable(true);
                        final ImageView imgPhoto = (ImageView) dialog.findViewById(R.id.imgPhoto);
                        dialog.show();
                        gp.getPhotoBitmapByWidth(array_photo.get(arg2), 600, "", new OnBitmapResponseListener() {

                            public void onResponse(Bitmap bm, String tag) {
                                imgPhoto.setImageBitmap(bm);
                            }
                        });
                    }
                });
            }
        }
    });
    gp.getNearby(latitude, longitude, radius, type, language, keyword);
}
Also used : ContentValues(android.content.ContentValues) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) Document(org.w3c.dom.Document) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Bitmap(android.graphics.Bitmap) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) Dialog(android.app.Dialog) AdapterView(android.widget.AdapterView) OnBitmapResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener) ImageView(android.widget.ImageView) ArrayAdapter(android.widget.ArrayAdapter)

Example 17 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Klyph by jonathangerbaud.

the class MultiSelectDragListPreference method onPrepareDialogBuilder.

@Override
protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);
    if (mEntries == null || mEntryValues == null) {
        throw new IllegalStateException("MultiSelectListPreference requires an entries array and " + "an entryValues array.");
    }
    String[] entries = new String[mEntries.length];
    for (int i = 0; i < mEntries.length; i++) {
        entries[i] = mEntries[i].toString();
    }
    boolean[] selectedItems = getSelectedItems();
    ArrayList<String> orderedList = new ArrayList<String>();
    int n = selectedItems.length;
    for (String value : mValues) {
        int index = ArrayUtils.indexOf(mEntryValues, value);
        orderedList.add(mEntries[index].toString());
    }
    for (int i = 0; i < mEntries.length; i++) {
        if (!mValues.contains(mEntryValues[i]))
            orderedList.add(mEntries[i].toString());
    }
    adapter = new ArrayAdapter<String>(getContext(), R.layout.item_list_preference_multi_drag, R.id.text, orderedList);
    listView = new DragSortListView(getContext(), null);
    listView.setAdapter(adapter);
    listView.setDropListener(onDrop);
    listView.setDragEnabled(true);
    listView.setFloatAlpha(0.8f);
    DragSortController controller = new DragSortController(listView);
    controller.setDragHandleId(R.id.drag_handle);
    controller.setRemoveEnabled(false);
    controller.setSortEnabled(true);
    controller.setBackgroundColor(0xFFFFFF);
    controller.setDragInitMode(DragSortController.ON_DOWN);
    listView.setFloatViewManager(controller);
    listView.setOnTouchListener(controller);
    builder.setView(listView);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            mPreferenceChanged = true;
            refreshNewValues();
        }
    });
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    for (int i = 0; i < n; i++) {
        listView.setItemChecked(i, i < mValues.size());
    }
    /*
		 * boolean [] checkedItems = getSelectedItems();
		 * builder.setMultiChoiceItems(mEntries, checkedItems,
		 * new DialogInterface.OnMultiChoiceClickListener() {
		 * public void onClick(DialogInterface dialog, int which, boolean 
		 * isChecked) {
		 * if (isChecked) {
		 * mPreferenceChanged |= mNewValues.add(mEntryValues[which].toString());
		 * } else {
		 * mPreferenceChanged |=
		 * mNewValues.remove(mEntryValues[which].toString());
		 * }
		 * }
		 * });
		 */
    mNewValues.clear();
    mNewValues.addAll(mValues);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) DragSortListView(com.mobeta.android.dslv.DragSortListView) DragSortListView(com.mobeta.android.dslv.DragSortListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) DragSortController(com.mobeta.android.dslv.DragSortController)

Example 18 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SlidingMenu by jfeinstein10.

the class BirdGridFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mPos == -1 && savedInstanceState != null)
        mPos = savedInstanceState.getInt("mPos");
    TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
    mImgRes = imgs.getResourceId(mPos, -1);
    GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null);
    gv.setBackgroundResource(android.R.color.black);
    gv.setAdapter(new GridAdapter());
    gv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (getActivity() == null)
                return;
            ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity();
            activity.onBirdPressed(mPos);
        }
    });
    return gv;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) TypedArray(android.content.res.TypedArray) GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 19 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project KJFrameForAndroid by kymjs.

the class BlogAuthorFragment method initWidget.

@Override
protected void initWidget(View parentView) {
    super.initWidget(parentView);
    mEmptyLayout.setOnLayoutClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
            refresh();
        }
    });
    mListView = mRefreshLayout.getRefreshView();
    mListView.setDivider(new ColorDrawable(android.R.color.transparent));
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Bundle bundle = new Bundle();
            bundle.putInt(OSCBlogListFragment.BLOGLIST_KEY, adapter.getItem(position).getId());
            bundle.putString(AUTHOR_NAME_KEY, adapter.getItem(position).getName());
            SimpleBackActivity.postShowWith(outsideAty, SimpleBackPage.OSC_BLOG_LIST, bundle);
        }
    });
    mRefreshLayout.setPullLoadEnabled(true);
    ((FooterLoadingLayout) mRefreshLayout.getFooterLoadingLayout()).setNoMoreDataText("学习不可贪多哦");
    mRefreshLayout.setOnRefreshListener(new OnRefreshListener<ListView>() {

        @Override
        public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
            refresh();
        }

        @Override
        public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
            mRefreshLayout.setHasMoreData(false);
        }
    });
    fillUI();
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) View(android.view.View) BindView(org.kymjs.kjframe.ui.BindView) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) FooterLoadingLayout(org.kymjs.blog.ui.widget.listview.FooterLoadingLayout) ListView(android.widget.ListView) ColorDrawable(android.graphics.drawable.ColorDrawable) OnClickListener(android.view.View.OnClickListener)

Example 20 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Klyph by jonathangerbaud.

the class GalleryFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    loadingView = (ProgressBar) view.findViewById(android.R.id.progress);
    setListVisible(false);
    super.onViewCreated(view, savedInstanceState);
    imageUris = new ArrayList<String>();
    getGridView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    getGridView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> gridView, View view, int position, long id) {
            GraphObject o = getAdapter().getItem(position);
            if (o instanceof CameraObject) {
                Intent intent = new Intent(getActivity(), GalleryActivity.class);
                intent.putExtra(KlyphBundleExtras.CAMERA_PICTURES, true);
                intent.putStringArrayListExtra(KlyphBundleExtras.PHOTO_LIST_URI, (ArrayList<String>) initUris);
                startActivityForResult(intent, CAMERA_GALLERY_CODE);
            } else {
                if (!Android.isMinAPI(11)) {
                    CheckableGalleryLayout cgl = (CheckableGalleryLayout) view;
                    cgl.toggle();
                    Picture image = (Picture) o;
                    image.setSelected(cgl.isChecked());
                }
                if (actionMode == null)
                    actionMode = getActivity().startActionMode(mActionModeCallback);
                refreshActionModeTitle();
            }
        }
    });
    showCamera = !getActivity().getIntent().getBooleanExtra(KlyphBundleExtras.CAMERA_PICTURES, false);
    hasCamera = getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) || getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    defineEmptyText(R.string.empty_list_no_photo);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) Intent(android.content.Intent) GalleryActivity(com.abewy.android.apps.klyph.app.GalleryActivity) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) CheckableGalleryLayout(com.abewy.android.apps.klyph.widget.CheckableGalleryLayout)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)135 AdapterView (android.widget.AdapterView)134 View (android.view.View)133 ListView (android.widget.ListView)102 TextView (android.widget.TextView)71 Intent (android.content.Intent)43 ImageView (android.widget.ImageView)41 OnClickListener (android.view.View.OnClickListener)24 Bundle (android.os.Bundle)18 ArrayAdapter (android.widget.ArrayAdapter)17 SuppressLint (android.annotation.SuppressLint)15 Paint (android.graphics.Paint)12 ColorDrawable (android.graphics.drawable.ColorDrawable)11 GridView (android.widget.GridView)11 LayoutInflater (android.view.LayoutInflater)10 DialogInterface (android.content.DialogInterface)9 CheckBox (android.widget.CheckBox)9 LinearLayout (android.widget.LinearLayout)9 ArrayList (java.util.ArrayList)7 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)6