Search in sources :

Example 11 with ArrayAdapter

use of android.widget.ArrayAdapter in project UltimateAndroid by cymcsg.

the class UltimateRecyclerViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ultimate_recyclerview_activity);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
    ultimateRecyclerView.setHasFixedSize(false);
    final List<String> stringList = new ArrayList<>();
    stringList.add("111");
    stringList.add("aaa");
    stringList.add("222");
    stringList.add("33");
    stringList.add("44");
    stringList.add("55");
    stringList.add("66");
    stringList.add("11771");
    simpleRecyclerViewAdapter = new SimpleAdapter(stringList);
    linearLayoutManager = new LinearLayoutManager(this);
    ultimateRecyclerView.setLayoutManager(linearLayoutManager);
    ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
    StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(simpleRecyclerViewAdapter);
    ultimateRecyclerView.addItemDecoration(headersDecor);
    ultimateRecyclerView.enableLoadmore();
    simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
    ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
    ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() {

        @Override
        public void onParallaxScroll(float percentage, float offset, View parallax) {
            Drawable c = toolbar.getBackground();
            c.setAlpha(Math.round(127 + percentage * 128));
            toolbar.setBackgroundDrawable(c);
        }
    });
    ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff"));
    ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    simpleRecyclerViewAdapter.insert(moreNum++ + "  Refresh things", 0);
                    ultimateRecyclerView.setRefreshing(false);
                    //   ultimateRecyclerView.scrollBy(0, -50);
                    linearLayoutManager.scrollToPosition(0);
                //                        ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
                //                        simpleRecyclerViewAdapter.notifyDataSetChanged();
                }
            }, 1000);
        }
    });
    ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {

        @Override
        public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                public void run() {
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                // linearLayoutManager.scrollToPositionWithOffset(maxLastVisiblePosition,-1);
                //   linearLayoutManager.scrollToPosition(maxLastVisiblePosition);
                }
            }, 1000);
        }
    });
    //        ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright),
    //                getResources().getColor(android.R.color.holo_green_light),
    //                getResources().getColor(android.R.color.holo_orange_light),
    //                getResources().getColor(android.R.color.holo_red_light));
    ultimateRecyclerView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() {

        @Override
        public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        }

        @Override
        public void onDownMotionEvent() {
        }

        @Override
        public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) {
            if (observableScrollState == ObservableScrollState.DOWN) {
                ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
                ultimateRecyclerView.showFloatingActionMenu();
            } else if (observableScrollState == ObservableScrollState.UP) {
                ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
                ultimateRecyclerView.hideFloatingActionMenu();
            } else if (observableScrollState == ObservableScrollState.STOP) {
            }
        }
    });
    ultimateRecyclerView.showFloatingButtonView();
    ultimateRecyclerView.addOnItemTouchListener(new SwipeableRecyclerViewTouchListener(ultimateRecyclerView.mRecyclerView, new SwipeableRecyclerViewTouchListener.SwipeListener() {

        @Override
        public boolean canSwipe(int position) {
            if (position > 0)
                return true;
            else
                return false;
        }

        @Override
        public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                simpleRecyclerViewAdapter.remove(position);
            }
            simpleRecyclerViewAdapter.notifyDataSetChanged();
        }

        @Override
        public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                simpleRecyclerViewAdapter.remove(position);
            }
            simpleRecyclerViewAdapter.notifyDataSetChanged();
        }
    }));
    ItemTouchListenerAdapter itemTouchListenerAdapter = new ItemTouchListenerAdapter(ultimateRecyclerView.mRecyclerView, new ItemTouchListenerAdapter.RecyclerViewOnItemClickListener() {

        @Override
        public void onItemClick(RecyclerView parent, View clickedView, int position) {
        }

        @Override
        public void onItemLongClick(RecyclerView parent, View clickedView, int position) {
            URLogs.d("onItemLongClick()" + isDrag);
            if (isDrag) {
                URLogs.d("onItemLongClick()" + isDrag);
                dragDropTouchListener.startDrag();
                ultimateRecyclerView.enableDefaultSwipeRefresh(false);
            }
        }
    });
    ultimateRecyclerView.mRecyclerView.addOnItemTouchListener(itemTouchListenerAdapter);
    dragDropTouchListener = new DragDropTouchListener(ultimateRecyclerView.mRecyclerView, this) {

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }

        @Override
        protected void onItemSwitch(RecyclerView recyclerView, int from, int to) {
            if (from > 0 && to > 0) {
                simpleRecyclerViewAdapter.swapPositions(from, to);
                //                    //simpleRecyclerViewAdapter.clearSelection(from);
                //                    simpleRecyclerViewAdapter.notifyItemChanged(to);
                //simpleRecyclerViewAdapter.remove(position);
                //  simpleRecyclerViewAdapter.notifyDataSetChanged();
                URLogs.d("switch----");
            //    simpleRecyclerViewAdapter.insert(simpleRecyclerViewAdapter.remove(););
            }
        }

        @Override
        protected void onItemDrop(RecyclerView recyclerView, int position) {
            URLogs.d("drop----");
            ultimateRecyclerView.enableDefaultSwipeRefresh(true);
            simpleRecyclerViewAdapter.notifyDataSetChanged();
        }
    };
    dragDropTouchListener.setCustomDragHighlight(getResources().getDrawable(R.drawable.custom_drag_frame));
    ultimateRecyclerView.mRecyclerView.addOnItemTouchListener(dragDropTouchListener);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ultimateRecyclerView.setItemAnimator(Type.values()[position].getAnimator());
            ultimateRecyclerView.getItemAnimator().setAddDuration(300);
            ultimateRecyclerView.getItemAnimator().setRemoveDuration(300);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleRecyclerViewAdapter.insert("newly added item", 1);
        }
    });
    findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleRecyclerViewAdapter.remove(1);
        }
    });
//        ultimateRecyclerView.addItemDecoration(
//                new HorizontalDividerItemDecoration.Builder(this).build());
//        ultimateRecyclerView.setCustomSwipeToRefresh();
//        final StoreHouseHeader header = new StoreHouseHeader(this);
//        //   header.setPadding(0, 15, 0, 0);
//
//        header.initWithString("Marshal Chen");
//        //  header.initWithStringArray(R.array.akta);
//        ultimateRecyclerView.mPtrFrameLayout.setHeaderView(header);
//        ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(header);
//
//        ultimateRecyclerView.mPtrFrameLayout.setPtrHandler(new PtrHandler() {
//            @Override
//            public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) {
//                boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2);
//                return canbePullDown;
//            }
//
//            @Override
//            public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
//                ptrFrameLayout.postDelayed(new Runnable() {
//                    @Override
//                    public void run() {
//                        simpleRecyclerViewAdapter.insert("Refresh things", 0);
//                        //   ultimateRecyclerView.scrollBy(0, -50);
//                        linearLayoutManager.scrollToPosition(0);
//                        ultimateRecyclerView.mPtrFrameLayout.refreshComplete();
//                    }
//                }, 1800);
//            }
//        });
}
Also used : ObservableScrollState(com.marshalchen.ultimaterecyclerview.ObservableScrollState) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SwipeableRecyclerViewTouchListener(com.marshalchen.ultimaterecyclerview.SwipeableRecyclerViewTouchListener) ItemTouchListenerAdapter(com.marshalchen.ultimaterecyclerview.ItemTouchListenerAdapter) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) ObservableScrollViewCallbacks(com.marshalchen.ultimaterecyclerview.ObservableScrollViewCallbacks) StickyRecyclerHeadersDecoration(com.marshalchen.ultimaterecyclerview.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) DragDropTouchListener(com.marshalchen.ultimaterecyclerview.DragDropTouchListener) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 12 with ArrayAdapter

use of android.widget.ArrayAdapter in project V2HOT by djyde.

the class TitleListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_title_list);
    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.pull);
    final ArrayAdapter<Topic> topicsAdapter = new ArrayAdapter<Topic>(this, 0) {

        private final LayoutInflater inflater = LayoutInflater.from(getContext());

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.topic_item, parent, false);
            }
            TextView title = (TextView) convertView.findViewById(R.id.title);
            title.setText(getItem(position).title);
            return convertView;
        }
    };
    final ListView topicsView = (ListView) findViewById(R.id.topics);
    topicsView.setAdapter(topicsAdapter);
    topicsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Topic topic = topicsAdapter.getItem(position);
            Intent intent = new Intent(TitleListActivity.this, ContentActivity.class);
            intent.putExtra("id", topic.id);
            intent.putExtra("title", topic.title);
            intent.putExtra("username", topic.member.username);
            intent.putExtra("url", topic.url);
            intent.putExtra("content", topic.content);
            startActivity(intent);
        }
    });
    //创建volley请求队列
    final RequestQueue queue = Volley.newRequestQueue(this);
    //根据API获取热议主题
    final GsonRequest<TopicList> request = new GsonRequest<TopicList>(Request.Method.GET, "https://www.v2ex.com/api/topics/hot.json", TopicList.class, new Response.Listener<TopicList>() {

        @Override
        public void onResponse(TopicList response) {
            topicsAdapter.clear();
            topicsAdapter.addAll(response);
            topicsAdapter.notifyDataSetChanged();
            swipeRefreshLayout.setRefreshing(false);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(TitleListActivity.this, "请检查网络", Toast.LENGTH_LONG).show();
        }
    });
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            queue.add(request);
        }
    });
    queue.add(request);
    swipeRefreshLayout.setRefreshing(true);
}
Also used : GsonRequest(com.v2ex.api.GsonRequest) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ListView(android.widget.ListView) RequestQueue(com.android.volley.RequestQueue) TopicList(com.v2ex.api.TopicList) TextView(android.widget.TextView) Topic(com.v2ex.api.Topic) VolleyError(com.android.volley.VolleyError) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Response(com.android.volley.Response) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 13 with ArrayAdapter

use of android.widget.ArrayAdapter in project UltimateRecyclerView by cymcsg.

the class LauncherActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launcher);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
    ultimateRecyclerView.setHasFixedSize(false);
    final List<String> stringList = new ArrayList<>();
    stringList.add("111");
    stringList.add("aaa");
    stringList.add("222");
    stringList.add("33");
    stringList.add("44");
    stringList.add("55");
    stringList.add("66");
    stringList.add("11771");
    simpleRecyclerViewAdapter = new SimpleAdapter(stringList);
    linearLayoutManager = new LinearLayoutManager(this);
    ultimateRecyclerView.setLayoutManager(linearLayoutManager);
    StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(simpleRecyclerViewAdapter);
    ultimateRecyclerView.addItemDecoration(headersDecor);
    ////        ultimateRecyclerView.setEmptyView(getResources().getIdentifier("empty_view","layout",getPackageName()));
    //        ultimateRecyclerView.showEmptyView();
    //  ultimateRecyclerView.enableLoadmore();
    //simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this)
    //        .inflate(R.layout.custom_bottom_progressbar, null));
    ultimateRecyclerView.setLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
    ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
    //        //   ultimateRecyclerView.setNormalHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
    ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() {

        @Override
        public void onParallaxScroll(float percentage, float offset, View parallax) {
            Drawable c = toolbar.getBackground();
            c.setAlpha(Math.round(127 + percentage * 128));
            toolbar.setBackgroundDrawable(c);
        }
    });
    ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff"));
    ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    simpleRecyclerViewAdapter.insert(moreNum++ + "  Refresh things", 0);
                    ultimateRecyclerView.setRefreshing(false);
                    //   ultimateRecyclerView.scrollBy(0, -50);
                    linearLayoutManager.scrollToPosition(0);
                //                        ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
                //                        simpleRecyclerViewAdapter.notifyDataSetChanged();
                }
            }, 1000);
        }
    });
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(simpleRecyclerViewAdapter);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(ultimateRecyclerView.mRecyclerView);
    simpleRecyclerViewAdapter.setOnDragStartListener(new SimpleAdapter.OnStartDragListener() {

        @Override
        public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
            mItemTouchHelper.startDrag(viewHolder);
        }
    });
    ultimateRecyclerView.reenableLoadmore();
    ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
    ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {

        @Override
        public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                public void run() {
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                // linearLayoutManager.scrollToPositionWithOffset(maxLastVisiblePosition,-1);
                //   linearLayoutManager.scrollToPosition(maxLastVisiblePosition);
                }
            }, 1000);
        }
    });
    //        ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright),
    //                getResources().getColor(android.R.color.holo_green_light),
    //                getResources().getColor(android.R.color.holo_orange_light),
    //                getResources().getColor(android.R.color.holo_red_light));
    //        ultimateRecyclerView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() {
    //            @Override
    //            public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    //
    //            }
    //
    //            @Override
    //            public void onDownMotionEvent() {
    //
    //            }
    //
    //            @Override
    //            public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) {
    ////                if (observableScrollState == ObservableScrollState.DOWN) {
    ////                    ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
    ////                    ultimateRecyclerView.showFloatingActionMenu();
    ////                } else if (observableScrollState == ObservableScrollState.UP) {
    ////                    ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
    ////                    ultimateRecyclerView.hideFloatingActionMenu();
    ////                } else if (observableScrollState == ObservableScrollState.STOP) {
    ////                }
    //                URLogs.d("onUpOrCancelMotionEvent");
    //                if (observableScrollState == ObservableScrollState.UP) {
    //                    ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
    //                    ultimateRecyclerView.hideFloatingActionMenu();
    //                } else if (observableScrollState == ObservableScrollState.DOWN) {
    //                    ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
    //                    ultimateRecyclerView.showFloatingActionMenu();
    //                }
    //            }
    //        });
    ultimateRecyclerView.showFloatingButtonView();
    //
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ultimateRecyclerView.setItemAnimator(Type.values()[position].getAnimator());
            ultimateRecyclerView.getItemAnimator().setAddDuration(500);
            ultimateRecyclerView.getItemAnimator().setRemoveDuration(500);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleRecyclerViewAdapter.insert("newly added item", 1);
        }
    });
    findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleRecyclerViewAdapter.remove(1);
        }
    });
//
}
Also used : SimpleItemTouchHelperCallback(com.marshalchen.ultimaterecyclerview.itemTouchHelper.SimpleItemTouchHelperCallback) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) StickyRecyclerHeadersDecoration(com.marshalchen.ultimaterecyclerview.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 14 with ArrayAdapter

use of android.widget.ArrayAdapter in project UltimateRecyclerView by cymcsg.

the class TestAdvancedAdmobActivity method setup_spinner.

private void setup_spinner() {
    final Spinner spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setPrompt("test functions");
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    spinnerAdapter.add("noth");
    spinnerAdapter.add("remove all");
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            //   ultimateRecyclerView.getItemAnimator().setRemoveDuration(300);
            if (position == 1) {
                remove_all_items();
                spinner.setSelection(0, true);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) AdView(com.google.android.gms.ads.AdView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ArrayAdapter(android.widget.ArrayAdapter)

Example 15 with ArrayAdapter

use of android.widget.ArrayAdapter in project FlexibleAdapter by davideas.

the class BottomSheetDialog method createPopUps.

private void createPopUps() {
    //Create the Adapter
    if (mAdapterReference == null) {
        mAdapterItemType = new ArrayAdapter(getContext(), R.layout.reference_spinner_item, new String[] { "Simple Item", "Expandable", "Expandable Section", "Section" });
        mAdapterReference = new ArrayAdapter(getContext(), R.layout.reference_spinner_item, getListener().getReferenceList());
    }
    //Setting up the popups
    Log.d(TAG, "Setting up the Popups");
    //Item Type
    mPopupItemType = new ListPopupWindow(getContext());
    mPopupItemType.setAnchorView(mBottomSheetDialog.findViewById(R.id.select_item_type));
    mPopupItemType.setModal(true);
    mPopupItemType.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopupItemType.setAnimationStyle(android.R.style.Animation_Dialog);
    mPopupItemType.setAdapter(mAdapterItemType);
    mPopupItemType.setVerticalOffset(-100);
    //Header Reference
    mPopupReference = new ListPopupWindow(getContext());
    mPopupReference.setAnchorView(mBottomSheetDialog.findViewById(R.id.select_reference_button));
    mPopupReference.setModal(true);
    mPopupReference.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopupReference.setAnimationStyle(android.R.style.Animation_Dialog);
    mPopupReference.setAdapter(mAdapterReference);
    mPopupReference.setVerticalOffset(-100);
    if (mAdapterReference.getCount() > 6)
        mPopupReference.setHeight(getResources().getDimensionPixelSize(R.dimen.popup_max_height));
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ArrayAdapter (android.widget.ArrayAdapter)292 View (android.view.View)150 TextView (android.widget.TextView)99 ListView (android.widget.ListView)88 AdapterView (android.widget.AdapterView)87 ArrayList (java.util.ArrayList)52 Spinner (android.widget.Spinner)51 ViewGroup (android.view.ViewGroup)39 Intent (android.content.Intent)31 AutoCompleteTextView (android.widget.AutoCompleteTextView)29 Button (android.widget.Button)26 ImageView (android.widget.ImageView)26 ListAdapter (android.widget.ListAdapter)21 DialogInterface (android.content.DialogInterface)20 LayoutInflater (android.view.LayoutInflater)18 LinearLayout (android.widget.LinearLayout)18 Bundle (android.os.Bundle)17 RecyclerView (android.support.v7.widget.RecyclerView)17 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)17 EditText (android.widget.EditText)15