Example usage for android.widget AdapterView getAdapter

List of usage examples for android.widget AdapterView getAdapter

Introduction

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

Prototype

public abstract T getAdapter();

Source Link

Document

Returns the adapter currently associated with this widget.

Usage

From source file:it.geosolutions.android.map.fragment.FeaturePolygonLayerListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    //init progress bar and loading text
    startLoadingGUI();/*from w ww  . j a va2 s.c  om*/
    //set the click listener for the items
    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(view.getContext(), GetFeatureInfoAttributeActivity.class);
            i.putExtras(getActivity().getIntent().getExtras());
            i.removeExtra("layers");
            // add a list with only one layer
            ArrayList<String> subList = new ArrayList<String>();
            FeaturePolygonQueryResult item = (FeaturePolygonQueryResult) parent.getAdapter().getItem(position);
            subList.add(item.getLayerName());
            i.putExtra("layers", subList);
            i.putExtra("start", 0);
            i.putExtra("limit", 1);
            //don't allow picking the position 
            String action = getActivity().getIntent().getAction();
            i.setAction(action);
            getActivity().startActivityForResult(i, GetFeatureInfoAttributeActivity.GET_ITEM);
        }
    });
}

From source file:it.geosolutions.android.map.fragment.FeatureInfoLayerListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    //init progress bar and loading text
    startLoadingGUI();/*from w w w  . j  a v a 2 s  .  c om*/
    //set the click listener for the items
    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(view.getContext(), GetFeatureInfoAttributeActivity.class);
            i.putExtras(getActivity().getIntent().getExtras());
            i.removeExtra("layers");
            // add a list with only one layer
            ArrayList<String> subList = new ArrayList<String>();
            FeatureInfoQueryResult item = (FeatureInfoQueryResult) parent.getAdapter().getItem(position);
            subList.add(item.getLayerName());
            i.putExtra("layers", subList);
            i.putExtra("start", 0);
            i.putExtra("limit", 1);
            //don't allow picking the position 
            String action = getActivity().getIntent().getAction();
            i.setAction(action);
            getActivity().startActivityForResult(i, GetFeatureInfoAttributeActivity.GET_ITEM);
        }
    });
}

From source file:it.geosolutions.android.map.fragment.featureinfo.FeatureInfoLayerListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    //init progress bar and loading text
    startLoadingGUI();//from w ww . j  a  va 2s  .  c  o m
    //set the click listener for the items
    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(view.getContext(), GetFeatureInfoAttributeActivity.class);
            i.putExtras(getActivity().getIntent().getExtras());
            i.removeExtra(Constants.ParamKeys.LAYERS);
            // add a list with only one layer
            ArrayList<Layer<?>> subList = new ArrayList<Layer<?>>();
            FeatureInfoQueryResult item = (FeatureInfoQueryResult) parent.getAdapter().getItem(position);
            subList.add(item.getLayer());
            i.putExtra(Constants.ParamKeys.LAYERS, subList);
            i.putExtra("start", 0);
            i.putExtra("limit", 1);
            //don't allow picking the position 
            String action = getActivity().getIntent().getAction();
            i.setAction(action);
            getActivity().startActivityForResult(i, GetFeatureInfoAttributeActivity.GET_ITEM);
        }
    });
}

From source file:it.geosolutions.android.map.fragment.FeatureCircleLayerListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    //init progress bar and loading text
    startLoadingGUI();//from   ww w  .  j a va 2 s  . c o  m
    //set the click listener for the items
    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(view.getContext(), GetFeatureInfoAttributeActivity.class);
            i.putExtras(getActivity().getIntent().getExtras());
            i.removeExtra("layers");
            // add a list with only one layer
            ArrayList<String> subList = new ArrayList<String>();
            FeatureCircleQueryResult item = (FeatureCircleQueryResult) parent.getAdapter().getItem(position);
            subList.add(item.getLayerName());
            i.putExtra("layers", subList);
            i.putExtra("start", 0);
            i.putExtra("limit", 1);
            //don't allow picking the position 
            String action = getActivity().getIntent().getAction();
            i.setAction(action);
            getActivity().startActivityForResult(i, GetFeatureInfoAttributeActivity.GET_ITEM);
        }
    });
}

From source file:biz.easymenu.easymenung.MenuPagerAdapter.java

private Object instantiateItemGrid(View pager, int position) {
    View v = li.inflate(R.layout.menupager, null);
    GridView listview = (GridView) v.findViewById(R.id.gridview);
    TextView tv = (TextView) v.findViewById(R.id.menuTitle);
    tv.setText(menuTitles.get(position).getLabel());

    ItemAdapter adapter = new ItemAdapter(context, position);
    ItemAdaptersList.add(position, adapter);
    listview.setAdapter(adapter);/* w  w w. j  a v  a  2 s. co  m*/

    listview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            //Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show();
            FragmentManager fm = ((FragmentActivity) context).getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            DialogFragment f = new ItemFragment((DBRowItem) parent.getAdapter().getItem(position));
            Fragment prev = fm.findFragmentByTag("itemDialog");
            if (prev != null) {
                ft.remove(prev);
                ft.commit();
            }
            f.show(ft, "itemDialog");
        }
    });
    ((ViewPager) pager).addView(v, 0);
    return v;
}

From source file:com.ymt.demo1.plates.hub.MyHubFragment.java

protected void initView(View view) {

    pullToRefreshListView = (PullToRefreshListView) view.findViewById(R.id.pull_to_refresh_list_view);

    scrollView.setListView(pullToRefreshListView); //???listView?
    switch (type) {
    case MY_POST: //?
        hubPostAdapter = new MyHubPostAdapter(getActivity());
        pullToRefreshListView.setAdapter(hubPostAdapter);
        break;/*w  ww.  ja  v  a 2 s .  c  o m*/
    case MY_REPLIES: //
        hubReplyAdapter = new MyHubReplyAdapter(getActivity());
        pullToRefreshListView.setAdapter(hubReplyAdapter);
        break;
    case MY_SYS_INFO: //?
        hubSysInfoAdapter = new MyHubSysInfoAdapter(getActivity());
        pullToRefreshListView.setAdapter(hubSysInfoAdapter);
        break;
    default:
        break;
    }

    pullToRefreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (type) {
            case MY_POST: //?
                Intent intent1 = new Intent(getActivity(), PostContentActivity.class);
                intent1.putExtra("tid", ((MyHubPost) parent.getAdapter().getItem(position)).getTid());
                intent1.putExtra("author", ((MyHubPost) (parent.getAdapter().getItem(position))).getAuthor());
                intent1.putExtra("subject", ((MyHubPost) (parent.getAdapter().getItem(position))).getSubject());
                startActivity(intent1);
                break;
            case MY_REPLIES: //
                Intent intent2 = new Intent(getActivity(), PostContentActivity.class);
                intent2.putExtra("tid", ((MyHubReply) parent.getAdapter().getItem(position)).getTid());
                intent2.putExtra("author",
                        ((MyHubReply) (parent.getAdapter().getItem(position))).getLastposter());
                intent2.putExtra("subject",
                        ((MyHubReply) (parent.getAdapter().getItem(position))).getSubject());
                startActivity(intent2);
                break;
            case MY_SYS_INFO: //?
                //todo ?
                break;
            default:
                break;
            }
        }
    });

    pullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
        @Override
        public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
            index = 1;
            switch (type) {
            case MY_POST: //?
                postList.clear();
                hubPostAdapter.setSubjects(postList);
                mQueue.add(getHubMyPost(AppContext.now_user_name, index));
                break;
            case MY_REPLIES: //
                replyList.clear();
                hubReplyAdapter.setSubjects(replyList);
                mQueue.add(getHubMyReplies(AppContext.now_user_name, index));
                break;
            case MY_SYS_INFO: //?
                mQueue.add(getHubSysInfo(AppContext.now_user_name));
                break;
            default:
                break;
            }
        }

        @Override
        public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
            index++;
            switch (type) {
            case MY_POST: //?
                mQueue.add(getHubMyPost(AppContext.now_user_name, index));
                break;
            case MY_REPLIES: //
                mQueue.add(getHubMyReplies(AppContext.now_user_name, index));
                break;
            case MY_SYS_INFO: //?
                mQueue.add(getHubSysInfo(AppContext.now_user_name));
                break;
            default:
                break;
            }
        }
    });

}

From source file:biz.easymenu.easymenung.MenuPagerAdapter.java

private Object instantiateItemList(View pager, int position) {
    View v = li.inflate(R.layout.menupager1, null);
    ListView listview = (ListView) v.findViewById(R.id.list);

    TextView tv = (TextView) v.findViewById(R.id.menuTitle);
    tv.setText(menuTitles.get(position).getLabel());

    ItemAdapter adapter = new ItemAdapter(context, position);
    ItemAdaptersList.add(position, adapter);
    listview.setAdapter(adapter);/*  w  ww.j  av  a  2 s .  c  o  m*/

    listview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            //Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show();
            FragmentManager fm = ((FragmentActivity) context).getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            DialogFragment f = new ItemFragment((DBRowItem) parent.getAdapter().getItem(position));
            Fragment prev = fm.findFragmentByTag("itemDialog");
            if (prev != null) {
                ft.remove(prev);
                ft.commit();
            }
            f.show(ft, "itemDialog");
        }
    });
    ((ViewPager) pager).addView(v, 0);
    return v;
}

From source file:com.easemob.chatuidemo.activity.GroupPickContactsActivity.java

private void initContactList(final List<User> contacts) {
    query.setAdapter(//w ww  .j  a  va2s  . c  o  m
            new PickContactsAutoCompleteAdapter(mContext, contacts, departments, roles, new ArrayList<>()));
    query.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            isTargeted = true;
            Object object = adapterView.getAdapter().getItem(i);
            if (object instanceof Role) {
                Role role = (Role) object;
                contactAdapter.setFilter(role, PickContactsAdapter.TYPE_ROLE);
                query.setText(role.getName());
            } else if (object instanceof Department) {
                Department department = (Department) object;
                contactAdapter.setFilter(department, PickContactsAdapter.TYPE_DEPARTMENT);
                query.setText(department.getName());
            } else if (object instanceof User) {
                User user = (User) object;
                contactAdapter.setFilter(user, PickContactsAdapter.TYPE_USER);
                query.setText(user.getNick());
            }
        }
    });
    query.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            handler.removeCallbacks(searchRunnable);
            if (!isTargeted) {
                if (editable.length() == 0) {
                    contactAdapter.setFilter(null, PickContactsAdapter.TYPE_ALL);
                } else {
                    clearSearch.setVisibility(View.VISIBLE);
                    handler.postDelayed(searchRunnable, 1000);
                }
            }
            isTargeted = false;
            selectedFilterCheckBox.setChecked(false);
        }
    });

    // list?
    Collections.sort(contacts, new Comparator<User>() {
        @Override
        public int compare(User lhs, User rhs) {
            int headerResult = lhs.getHeader().compareTo(rhs.getHeader());
            if (headerResult == 0) { // ??nick
                return (lhs.getNick().compareTo(rhs.getNick()));
            } else {
                return headerResult;
            }
        }
    });

    contactAdapter = new PickContactsAdapter(this, contacts, exitingMembers);
    listView.setAdapter(contactAdapter);
    listView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            InputMethodManager imm = (InputMethodManager) mContext
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(query.getWindowToken(), 0);
            return false;
        }
    });
    contactAdapter.setOnSelectedCountChangeListener(new PickContactsAdapter.OnSelectedCountChangeListener() {
        @Override
        public void onSelectedCountChange(int count) {
            setSelectedNumber(count);
            setAllSelectedStatus(contactAdapter.getAllSelectedStatus());
        }
    });
    contactAdapter.setOnDataSetChangedListener(new PickContactsAdapter.OnDataSetChangedListener() {
        @Override
        public void onDataSetChanged() {
            if (contactAdapter.getCount() > 0) {
                findViewById(R.id.none_result_view).setVisibility(View.GONE);
            } else {
                if (selectedFilterCheckBox.isChecked()) {

                } else {
                    findViewById(R.id.none_result_view).setVisibility(View.VISIBLE);
                }
            }
        }
    });

    // ??
    InputMethodManager inputMethodManager = (InputMethodManager) mActivity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mActivity.getWindow()
            .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (mActivity.getCurrentFocus() != null)
            inputMethodManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:com.jesjimher.bicipalma.MesProperesActivity.java

public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    ResultadoBusqueda rb = (ResultadoBusqueda) parent.getAdapter().getItem(position);
    // Ms rpido en posicionar, pero no muestra pin
    //      String uri="geo:"+rb.getEstacion().getLoc().getLatitude()+","+rb.getEstacion().getLoc().getLongitude();
    /*      String uri="geo:0,0?q="+rb.getEstacion().getLoc().getLatitude()+","+rb.getEstacion().getLoc().getLongitude()+" ("+rb.getEstacion().getNombre()+")";
          startActivity(new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(uri)));*/

    Intent i = new Intent(this, MapaActivity.class);
    i.putExtra("estaciones", estaciones);
    i.putExtra("latcentro", rb.getEstacion().getLoc().getLatitude());
    i.putExtra("longcentro", rb.getEstacion().getLoc().getLongitude());
    startActivity(i);/*from w  w w  .j  ava  2  s .co  m*/
}

From source file:com.luke.lukef.lukeapp.fragments.NewSubmissionFragment.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    CheckBox checkBox = (CheckBox) view.findViewById(R.id.popup_categories_checkbox);
    boolean checked = checkBox.isChecked();
    ((CheckBox) view.findViewById(R.id.popup_categories_checkbox)).setChecked(!checked);
    CategoriesPopup.ListViewAdapter listViewAdapter = (CategoriesPopup.ListViewAdapter) adapterView
            .getAdapter();/*from w w  w . j a v a2  s  .c  o  m*/

    if (!checked) {
        this.confirmedCategories.add(listViewAdapter.getItem(i));
    } else {
        this.confirmedCategories.remove(listViewAdapter.getItem(i));
    }

    Log.e(TAG, "onItemClick: confirmed size after change " + this.confirmedCategories.size());
}