List of usage examples for android.view View setTag
public void setTag(final Object tag)
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.MovieJSONAdapter.java
@Override public View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent) { MovieViewHolder vh;/* w w w . j a va 2 s .c o m*/ if (convertView == null) { convertView = inflater.inflate(R.layout.item_movie1, parent, false); vh = new MovieViewHolder(convertView); convertView.setTag(vh); } else { vh = (MovieViewHolder) convertView.getTag(); } try { JSONObject movie = optItemJSONObject(position); vh.title.setText(movie.getString(MovieItem.JSON_TITLE)); vh.subtitle.setText(movie.getString(MovieItem.JSON_YEAR)); vh.icon.setImageResource((movie.getBoolean(MovieItem.JSON_IS_RECOMMENDED)) ? R.drawable.ic_rating_good : R.drawable.ic_rating_bad); } catch (JSONException e) { Log.e(MovieJSONAdapter.class.getSimpleName(), "GetView error", e); } return convertView; }
From source file:com.roque.rueda.cashflows.adapters.AccountAdapter.java
/** * Makes a new view to hold the data pointed to by cursor. * /* w ww. j a va2 s.c o m*/ * @param context Interface to application's global information. * @param cursor The cursor from which to get the data. * The cursor is already moved to the correct position. * @param parent The parent to which the new view is attached to. * */ @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { final View view = mInflater.inflate(R.layout.account_list_item_nice, parent, false); // View holder that is used to avoid calls to find view by Id. AccountView holder = new AccountView(view, context.getResources()); view.setTag(holder); return view; }
From source file:com.barak.pix.PostsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_posts, container, false); rootView.setTag(TAG); mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); mDetailView = rootView.findViewById(R.id.detail); mTextView = (TextView) rootView.findViewById(R.id.detail_text); mTextView.setText(mFirebaseRemoteConfig.getString("upper")); mFirebaseRemoteConfig.setDefaults(new HashMap<String, Object>()); return rootView; }
From source file:com.example.android.animationsdemo.BoardFragment.java
public void addItem(View view) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View newCard = inflater.inflate(R.layout.new_card_layout, null, false); newCard.setTag("newCard"); ViewGroup parentCol = (ViewGroup) view.getParent(); ViewGroup svCol = (ViewGroup) parentCol.getChildAt(parentCol.getChildCount() - 1); ViewGroup containerCol = (ViewGroup) svCol.getChildAt(0); View check = containerCol.findViewWithTag("newCard"); if (check == null) containerCol.addView(newCard, 0); else//from w ww . j av a 2 s . c o m containerCol.removeView(check); ImageView save = (ImageView) newCard.findViewById(R.id.saveNewCard); final EditText title = (EditText) newCard.findViewById(R.id.newCardTitle); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view1) { if (isEmpty(title)) Toast.makeText(context, "Please enter a title", Toast.LENGTH_SHORT).show(); else { query = ""; pager.getAdapter().notifyDataSetChanged(); InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(title.getWindowToken(), 0); } // } }); }
From source file:com.lastsoft.plog.PlayersFragment_Players.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_players, container, false); rootView.setTag(TAG); // BEGIN_INCLUDE(initializeRecyclerView) mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller); fastScroller.attachRecyclerView(mRecyclerView); //VerticalRecyclerViewFastScroller fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller); // Connect the recycler to the scroller (to let the scroller scroll the list) //fastScroller.setRecyclerView(mRecyclerView, null); // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle) //mRecyclerView.setOnScrollListener(fastScroller.getOnScrollListener()); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(mActivity); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); }//from w ww . j av a 2 s.co m setRecyclerViewLayoutManager(mCurrentLayoutManagerType); mAdapter = new PlayerAdapter(mActivity, this, MainActivity.CurrentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); mRecyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { ((MainActivity) mActivity).showPlayerFAB(); } @Override public void hide() { ((MainActivity) mActivity).hidePlayerFAB(); } }); return rootView; }
From source file:com.manning.androidhacks.hack043.adapter.BatchAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View view = mInflater.inflate(R.layout.list_item, parent, false); ViewHolder holder = new ViewHolder(); holder.id = (TextView) view.findViewById(R.id.list_item_id); holder.number = (TextView) view.findViewById(R.id.list_item_number); view.setTag(holder); return view;/*from www. j a va 2s .c o m*/ }
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.UnitTestMovieAdapter.java
@Override public View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent) { UnitTestViewHolder vh;//from ww w . ja v a 2 s . co m if (convertView == null) { convertView = inflater.inflate(android.R.layout.two_line_list_item, parent, false); vh = new UnitTestViewHolder(convertView); convertView.setTag(vh); } else { vh = (UnitTestViewHolder) convertView.getTag(); } Object item = getItem(position); vh.title.setText(item.getClass().getSimpleName()); vh.subtitle.setText(item.toString()); return convertView; }
From source file:com.calciumion.widget.BasePagerAdapter.java
@Override public final void finishUpdate(ViewGroup container) { ArrayList<View> recycledViews = new ArrayList<View>(); // Remove views backing destroyed items from the specified container, // and queue them for recycling. for (int i = 0; destroyedItems.size() > 0 && i < container.getChildCount(); i++) { View v = container.getChildAt(i); Iterator<Object> it = destroyedItems.iterator(); while (it.hasNext()) { if (isViewFromObject(v, it.next())) { container.removeView(v); recycledViews.add(v);/*from w ww . j ava 2s. c o m*/ it.remove(); break; } } } // Render views and attach them to the container. Page views are reused // whenever possible. for (Object instantiatedItem : instantiatedItems) { View convertView = null; if (recycledViews.size() > 0) convertView = recycledViews.remove(0); convertView = getView(instantiatedItem, convertView, container); convertView.setTag(instantiatedItem); container.addView(convertView); } instantiatedItems.clear(); recycledViews.clear(); }
From source file:com.example.ali.topcoderandroid.ui.RecyclerViewFragment.java
@Nullable @Override// w ww . ja v a 2 s . c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.recyclerview_fragment, container, false); rootView.setTag(TAG); /*init recyclerview */ mRecyclerView = (ChallengeRecyclerView) rootView.findViewById(R.id.recyclerview); mRecyclerView.setEmptyView(rootView.findViewById(android.R.id.empty)); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(context); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); /*init adapter*/ ArrayList<ChallengeModel> emptyChallengeList = new ArrayList<>(); challengeRecyclerViewAdapter = new ChallengeRecyclerViewAdapter(context, emptyChallengeList); mRecyclerView.setAdapter(challengeRecyclerViewAdapter); /*init pull to refresh*/ swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(this); /* mLinearLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.linear_layout_rb); mLinearLayoutRadioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER); } }); mGridLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.grid_layout_rb); mGridLayoutRadioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerViewLayoutManager(LayoutManagerType.GRID_LAYOUT_MANAGER); } });*/ fetchChallenges(preferredChallengeType); return rootView; }
From source file:com.lugia.timetable.TimeTableFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "onCreateView()"); mColors = Utils.getForegroundColorArrays(getActivity()); mBackgrounds = Utils.getBackgroundDrawableResourceIds(); View view = inflater.inflate(R.layout.fragment_time_table, null); mTimeTable = (TimeTableLayout) view.findViewById(R.id.time_table); SubjectList subjects = SubjectList.getInstance(getActivity()); for (Subject subject : subjects) { int colorIndex = subject.getColor(); for (Schedule schedule : subject.getSchedules()) { View child = inflater.inflate(R.layout.item_time_table_schedule, mTimeTable, false); child.setBackgroundResource(mBackgrounds[colorIndex]); child.setTag(subject.getSubjectCode()); TextView subjectCodeTextView = (TextView) child.findViewById(R.id.text_subject_code); TextView subjectDescriptionTextView = (TextView) child.findViewById(R.id.text_subject_description); TextView sectionTextView = (TextView) child.findViewById(R.id.text_section); TextView roomTextView = (TextView) child.findViewById(R.id.text_room); subjectCodeTextView.setText(subject.getSubjectCode()); subjectDescriptionTextView.setText(subject.getSubjectDescription()); sectionTextView.setText(subject.getSection(schedule.getSection())); roomTextView.setText(schedule.getRoom()); subjectCodeTextView.setTextColor(mColors[colorIndex]); subjectDescriptionTextView.setTextColor(mColors[colorIndex]); sectionTextView.setTextColor(mColors[colorIndex]); roomTextView.setTextColor(mColors[colorIndex]); mTimeTable.addView(child, schedule.getDay(), schedule.getTime(), schedule.getLength()); }/* w w w .java2s . c om*/ } mTimeTable.setOnDayChangedListener((MasterActivity) getActivity()); mTimeTable.setOnItemClickListener(TimeTableFragment.this); // set the current day of this view initially according to real world day switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { case Calendar.SATURDAY: case Calendar.SUNDAY: mTimeTable.setCurrentDay(TimeTableLayout.MONDAY); break; default: mTimeTable.setCurrentDay(Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1); // scroll to current time position for user convenient mTimeTable.scrollToCurrentTime(); break; } return view; }