onItemClick with toast content of an array list - android-viewholder

What I need is a toast or something like that with content of an array list, that opens when I click on a LinearLayout item. But I don't know how to implement it with the holder view.
public class CanteenListAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private ArrayList<CanteenMenu> listData;
private LayoutInflater layoutInflater;
private Context context;
public CanteenListAdapter(ArrayList<CanteenMenu> listData, Context bContext){
this.listData = listData;
layoutInflater = LayoutInflater.from(bContext);
this.context = bContext;
Collections.sort(this.listData);
}
#Override
public int getCount() {
return listData.size();
}
#Override
public Object getItem(int position) {
return listData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View cView, ViewGroup parent) {
ViewHolder holder;
if(cView==null){
cView = layoutInflater.inflate(R.layout.activity_canteen_tab_listitem, null);
holder = new ViewHolder();
holder.date = (TextView) cView.findViewById(R.id.canteen_header);
holder.ll = (LinearLayout) cView.findViewById(R.id.canteen_linearLayout);
int j = 0;
for (int i = 0; i < listData.get(position).getCategory().length; i++) {
TextView description = new TextView(context);
TextView category = new TextView(context);
description.setText(listData.get(position).getName()[i]);
category.setText(listData.get(position).getCategory()[i]);
holder.ll.addView(category, j);
holder.ll.addView(description,j + 1);
j += 2;
}
cView.setTag(holder);
} else{
holder = (ViewHolder) cView.getTag();
}
int j = 0;
for(int i = 0; i < listData.get(position).getCategory().length; i++) {
if(holder.ll.getChildAt(j) != null) {
((TextView) holder.ll.getChildAt(j)).setText(listData.get(position).getCategory()[i]);
((TextView) holder.ll.getChildAt(j + 1)).setText(listData.get(position).getName()[i]);
}
j += 2;
}
return cView;
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
static class ViewHolder {
LinearLayout ll;
TextView date;
TextView name;
TextView category;
}
}
Can anyone help ?

Related

Grid view having duplicate column values

I am trying to build a Grid View inside Expandable list view. The problem i am facing is that the the columns in gridview are repeating no matter the number of columns i specify in xml. please find below the code and screen shot. That is there are two child view A and B. Instead of each coming in a single row. A is coming completely on 1st row no matter the number of columns and B is coming on the complete second rows.
ExpandableListAdapter
public class ExpandListAdapter extends BaseExpandableListAdapter {
private Activity activity;
private Context context;
private ArrayList<GroupModel> mMainDatabase;
private LayoutInflater inflater;
private ArrayList<String> parentItems, child, child1, child2;
private CustomGrid adapter;
private GridView grid;
ViewHolder viewHolder;
private static final String LOG_TAG = ExpandListAdapter.class.getSimpleName();
public ExpandListAdapter(ArrayList<GroupModel> mMainDatabase) {
this.mMainDatabase = mMainDatabase;
}
public void setInflater(LayoutInflater inflater, Activity activity) {
this.inflater = inflater;
this.activity = activity;
}
#Override
public int getGroupCount() {
return mMainDatabase.size();
}
#Override
public int getChildrenCount(int groupPosition) {
return mMainDatabase.get(groupPosition).getItemModels().size();
}
#Override
public Object getGroup(int groupPosition) {
return mMainDatabase.get(groupPosition);
}
#Override
public Object getChild(int groupPosition, int childPosition) {
return child.get(childPosition);
}
#Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
#Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
#Override
public boolean hasStableIds() {
return false;
}
#Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = convertView;
// if (convertView == null) {
// inflate the adapter_side
LayoutInflater vi = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.fragment_list_item, null);
// well set up the ViewHolder
viewHolder = new ViewHolder();
viewHolder.title = (TextView) v.findViewById(R.id.item_title);
viewHolder.image = (ImageView) v.findViewById(R.id.item_image);
viewHolder.image.setId(groupPosition);
if (mMainDatabase.get(groupPosition).getGroupImage() != null &&
!mMainDatabase.get(groupPosition).getGroupImage().equals(""))
Utilities.displayImage(activity.getApplicationContext(), mMainDatabase.get(groupPosition).getGroupImage(), viewHolder.image);
else
Picasso.with(activity).load("http://www.google.com")
.into(viewHolder.image);
viewHolder.title
.setText(mMainDatabase.get(groupPosition).getGroupName());
viewHolder.arrowExpand = (ImageView) v.findViewById(R.id.arrowExpand);
if (isExpanded)
viewHolder.arrowExpand.setImageResource(R.drawable.dropdown2);
else
viewHolder.arrowExpand.setImageResource(R.drawable.dropdown);
return v;
}
#Override
public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if (convertView == null) {
// LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.grid_view, null);
}
grid = (GridView) convertView.findViewById(R.id.grid);
adapter = new CustomGrid(activity, groupPosition, childPosition,activity, mMainDatabase);
grid.setAdapter(adapter);
grid.setTag(childPosition);
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(activity, FoodDetailActivity.class);
intent.putExtra("item", mMainDatabase.get(groupPosition).getItemModels().
get(Integer.parseInt(view.getTag().toString())));
intent.putExtra("grpId", mMainDatabase.get(groupPosition).get_id());
intent.putExtra("atBottom", true);
activity.startActivity(intent);
}
});
return convertView;
}
#Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
#TargetApi(Build.VERSION_CODES.JELLY_BEAN)
#Override
public void onGroupExpanded(int groupPosition) {
super.onGroupExpanded(groupPosition);
}
#SuppressLint("NewApi")
#Override
public void onGroupCollapsed(int groupPosition) {
super.onGroupCollapsed(groupPosition);
// ImageView img_selection = (ImageView) groupPosition
// .findViewById(R.id.arrowExpand);
}
static class ViewHolder {
TextView title;
TextView number;
TextView numbertxt;
ImageView image, arrowExpand;
Bitmap b;
int position;
}
}
Custom Grid Adapter
public class CustomGrid extends BaseAdapter {
private Context mContext;
private ArrayList<String> mItemName = null;
private ArrayList<String> mItemImage = null;
private int groupPosition, childPosition;
Activity activity;
ArrayList<GroupModel> mMainDatabase;
LayoutInflater inflater;
public CustomGrid(Context c,
int groupPosition, int childPosition, Activity activity, ArrayList<GroupModel> mMainDatabase) {
mContext = c;
this.groupPosition = groupPosition;
this.childPosition = childPosition;
this.activity = activity;
this.mMainDatabase = mMainDatabase;
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return mMainDatabase.get(groupPosition).getItemModels().size();
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
grid = inflater.inflate(R.layout.grid_single, null);
TextView textView = (TextView) grid.findViewById(R.id.grid_text);
ImageView imageView = (ImageView)grid.findViewById(R.id.grid_image);
textView.setText(mMainDatabase.get(groupPosition).getItemModels()
.get(childPosition).getItemName());
Log.d("CUSTOMGRID", "child name is " + mMainDatabase.get(groupPosition).getItemModels()
.get(childPosition).getItemName() + " child position is " + childPosition);
if (mMainDatabase.get(groupPosition).getItemModels().get(childPosition).getItemImage() != null &&
!mMainDatabase.get(groupPosition).getItemModels().get(childPosition).getItemImage()
.equals(""))
Picasso.with(activity)
.load(mMainDatabase.get(groupPosition).getItemModels()
.get(childPosition).getItemImage())
.placeholder(R.drawable.place).into(imageView);
else
Picasso.with(activity).load("http://www.google.com")
.placeholder(R.drawable.place).into(imageView);
} else {
grid = (View) convertView;
}
return grid;
}
}

Error null exception in "for" construct xamarin android. Where is incorrect?

This method returns the number of types of Views that will be created by getView method.
public class CustomAdapter : BaseAdapter{
private const int TYPE_ITEM = 0;
private const int TYPE_SEPARATOR = 1;
private List<string> mData;
private TreeSet sectionHeader;
private LayoutInflater mInflater;
public CustomAdapter(Context context, List<string> Data) {
mInflater = (LayoutInflater) context
.GetSystemService(Context.LayoutInflaterService);
this.mData=Data;
}
public void addItem(string item) {
mData.Add(item);
NotifyDataSetChanged();
}
public void addSectionHeaderItem(string item) {
mData.Add(item);
//sectionHeader.Add(mData.Count - 1);
NotifyDataSetChanged();
}
public int getItemViewType(int position) {
return sectionHeader.Contains(position) ? TYPE_SEPARATOR : TYPE_ITEM;
}
public int getViewTypeCount {
get{ return 2; }
}
public override int Count {
get {return mData.Count;}
}
public override Java.Lang.Object GetItem(int position) {
return mData[position];
}
public override long GetItemId(int position) {
return position;
}
public override View GetView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
int rowType = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
switch (rowType) {
case TYPE_ITEM:
convertView = mInflater.Inflate(Resource.Layout.textViewItemsSeparator, parent);
holder.textView = (TextView) convertView.FindViewById(Resource.Id.textviewHeaderItems);
break;
case TYPE_SEPARATOR:
convertView = mInflater.Inflate(Resource.Layout.textViewHeaderItems, parent);
holder.textView = (TextView) convertView.FindViewById(Resource.Id.textviewItemsSeparator);
break;
}
convertView.Tag=holder;
} else {
holder = (ViewHolder)convertView.Tag as ViewHolder;
}
holder.textView.Text=mData[position];
return convertView;
}
public class ViewHolder:Java.Lang.Object {
public TextView textView;
}
}
ListView lst;
string[] items = new string[] { "Alternative Rock","Classical",...........};
List<string> listItems;
private CustomAdapter mAdapter;
public override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Create your fragment here
}
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
// return inflater.Inflate(Resource.Layout.YourFragment, container, false);
listItems = new List<string> (items);
return inflater.Inflate (Resource.Layout.GenerFragment, container, false);
}
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
lst = View.FindViewById<ListView> (Resource.Id.lstGenres);
//lst.Adapter = new ArrayAdapter<string>(Activity, Resource.Layout.textViewHeaderItems,Resource.Id.textviewHeaderItems, items);
//lst = View.FindViewById<ListView> (Resource.Id.lst_genre);
//lst.SetAdapter(new ArrayAdapter<String>(this.Activity, Resource.Layout.GenerFragment, items));
//mAdapter=new CustomAdapter();
for (int i = 0; i < listItems.Count(); i++) {
mAdapter.addItem (listItems[i]);
if (i == 0) {
mAdapter.addSectionHeaderItem ("Music");
} else if(i==13) {
mAdapter.addSectionHeaderItem ("Audio");
}
}
lst.Adapter = new CustomAdapter (Activity, listItems);
I spent much time for looking for errors but I have no idea why It was null. although It got a data from list
mAdapter.addItem (listItems[i]); -> null exception when I debug on device. Where is incorrect?
in OnActivityCreated you are referencing listItems
for (int i = 0; i < listItems.Count(); i++) {
however, listItems is null. You initialize it in OnCreateView, which has not been executed yet. You need to be sure that listItems is initialized before you attempt to reference it.
Additionally, you are attempting to add items to mAdapter, but it's never been initialized (as far as I can see)
you declare it here, but it will be NULL until you initalize it
private CustomAdapter mAdapter;
here is the initialization, which is commented out
//mAdapter=new CustomAdapter();
when you attempt to reference it here, it is still null, and will throw a Null Reference Exception
mAdapter.addItem (listItems[i]);

cannot convert CustomAdapter expression to type System.Collections.Generic.List<string> on xamarin android

string[] items = new string[] { "Alternative Rock","Classical", "Country"}
for (int i = 0; i <= items.Count(); i++) {
mAdapter.addItem (items [i].ToString ());
if (i == 0) {
mAdapter.addSectionHeaderItem ("Music");
} else if(i==13) {
mAdapter.addSectionHeaderItem ("Audio");
}
}
lst.Adapter = new CustomAdapter (Activity, mAdapter);
public class CustomAdapter : BaseAdapter{
private const int TYPE_ITEM = 0;
private const int TYPE_SEPARATOR = 1;
private List<string> mData;
private TreeSet sectionHeader;
private LayoutInflater mInflater;
public CustomAdapter(Context context, List<string> mData) {
mInflater = (LayoutInflater) context
.GetSystemService(Context.LayoutInflaterService);
this.mData=mData;
}
public void addItem( string item) {
mData.Add(item);
NotifyDataSetChanged();
}
public void addSectionHeaderItem(string item) {
mData.Add(item);
sectionHeader.Add(mData.Count - 1);
NotifyDataSetChanged();
}
public int getItemViewType(int position) {
return sectionHeader.Contains(position) ? TYPE_SEPARATOR : TYPE_ITEM;
}
public int getViewTypeCount {
get{ return 2; }
}
public override int Count {
get {return mData.Count;}
}
public override Java.Lang.Object GetItem(int position) {
return null;
}
public override long GetItemId(int position) {
return position;
}
public View GetView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
int rowType = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
switch (rowType) {
case TYPE_ITEM:
convertView = mInflater.Inflate(Resource.Layout.textViewItemsSeparator, parent);
holder.textView = (TextView) convertView.FindViewById(Resource.Id.textviewHeaderItems);
break;
case TYPE_SEPARATOR:
convertView = mInflater.Inflate(Resource.Layout.textViewHeaderItems, parent);
holder.textView = (TextView) convertView.FindViewById(Resource.Id.textviewItemsSeparator);
break;
}
convertView.Tag=holder;
} else {
holder = (ViewHolder)convertView.Tag as ViewHolder;
}
holder.textView.Text=mData[position];
return convertView;
}
public class ViewHolder:Java.Lang.Object {
public TextView textView;
}
cannot convert CustomAdapter expression to type System.Collections.Generic.List on xamarin android at
CustomAdapter : BaseAdapter and new CustomAdapter (Activity,
mAdapter);
Blockquote
In this example we will show how to create a ListView with section header. This involves following steps
Update my post.
the signature for your CustomAdapter constructor specifies two arguments, a context and a List<string>
public CustomAdapter(Context context, List<String> mData) {
however, when you create it, you are passing mAdapter for the 2nd argument instead of a List<string>.
lst.Adapter = new CustomAdapter (Activity, mAdapter);

How to create header xamarin listview?

lst.Adapter=new CustomAdapter(Android.App.Application.Context,items);
public class CustomAdapter : BaseAdapter
{
private const int TYPE_ITEM = 0;
private const int TYPE_SEPARATOR = 1;
string[] mnData;
//private TreeSet sectionHeader;
LayoutInflater mInflater;
TreeSet sectionHeader;
public CustomAdapter(Context context, string[] Data) {
mInflater = LayoutInflater.FromContext (context);
mnData=Data;
}
public override int GetItemViewType (int position)
{
return sectionHeader.Contains(position) ? TYPE_SEPARATOR : TYPE_ITEM;
}
public override int ViewTypeCount
{
get { return 2; }
}
public override int Count {
get {return mnData.Length;}
}
public override Java.Lang.Object GetItem(int position) {
return mnData[position];
}
public override long GetItemId(int position) {
return position;
}
public override View GetView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
//var data = mData [position];
var item=mnData[position];
int row = GetItemViewType (position);
if (convertView == null) {
holder = new ViewHolder ();
switch (row) {
case TYPE_ITEM:
convertView = mInflater.Inflate (Resource.Layout.textGenreItems, parent, false);
holder.textView = (TextView)convertView.FindViewById (Resource.Id.textTitleGenre);
break;
case TYPE_SEPARATOR:
convertView = mInflater.Inflate (Resource.Layout.textGenreHeaderItems, parent, false);
holder.textView = (TextView)convertView.FindViewById (Resource.Id.textHeaderGenre);
break;
}
convertView.Tag = holder;
} else {
holder = (ViewHolder)convertView.Tag as ViewHolder;
}
return convertView;
}
}
public class ViewHolder:Java.Lang.Object {
public TextView textView{ get; set; }
//public TextView textViewSeparator{ get; set; }
I want to create a listview as following picture. How to do that?
Here's how I do it, the keys are getItemViewType and getViewTypeCount in the Adapter class. getViewTypeCount returns how many types of items we have in the list, in this case we have a header item and an event item, so two. getItemViewType should return what type of View we have at the input position.
Android will then take care of passing you the right type of View in convertView automatically.

Memory leak with view pager and fragment

In this part of my application there is a ViewPager contents in a fragment,
when i replace the fragment contains the viewpager android doesn't clear the memory.
How can I clear the memory?
this is the adapter for the listview:
public class LineeAdapter extends ArrayAdapter<Linea> {
private final List<Linea> list;
private final Activity context;
private final int layout;
public LineeAdapter(Activity context,int layout, List<Linea> list) {
super(context, layout, list);
this.context = context;
this.list = list;
this.layout=layout;
}
static class ViewHolder {
protected TextView text;
protected TextView text1;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
view = inflator.inflate(layout, null);
final ViewHolder viewHolder = new ViewHolder();
viewHolder.text = (TextView) view.findViewById(R.id.cod_linea);
viewHolder.text1 = (TextView) view.findViewById(R.id.descrizione_linea);
view.setTag(viewHolder);
} else {
view = convertView;
}
ViewHolder holder = (ViewHolder) view.getTag();
holder.text.setText(list.get(position).getCod_Linea());
holder.text1.setText(list.get(position).getDesc_Linea());
return view;
}
this is the fragmet contain in the view pager
public class TempiAtt_Linee extends Fragment
{
View view;
ListView lw;
int dati;
LineeAdapter adapter;
List<Linea> linee ;
static TempiAtt_Linee newInstance(int num)
{
TempiAtt_Linee f = new TempiAtt_Linee();
return f;
}
#Override
public void onDestroyView()
{
super.onDestroyView();
getView().destroyDrawingCache();
linee.clear();
adapter.notifyDataSetChanged();
adapter.clear();
view = null;
lw = null;
linee = null;
System.gc();
}
#Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
linee= new ArrayList<Linea>();
for (int i = 0; i < Main.GeneralObject.getLinee().size(); i++)
{
this.linee.add(Main.GeneralObject.getLinee().get(i));
}
lw = (ListView) getView().findViewById(R.id.list_view);
adapter = new LineeAdapter(getActivity(), R.layout.row_linea, linee);
lw.setAdapter(adapter);
lw.setOnItemClickListener(new OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3)
{
ArrayList<Percorso> tratte = linee.get(position).getPercorsi();
Fragment fragment = new TempiAtt_Percorsi();
FragmentManager fragmentManager = getActivity()
.getSupportFragmentManager();
Bundle temp = new Bundle();
temp.putString("linea", linee.get(position).getCod_Linea()
.replace(" ", "_"));
temp.putSerializable("tratte",
SerializerClass.serializeObject(tratte));
fragment.setArguments(temp);
fragmentManager.beginTransaction().addToBackStack(null)
.replace(R.id.content_frame, fragment).commit();
}
});
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.generic_listview, container, false);
return view;
}
}
and this is the fragment of the viewpager:
public class TempiAtt extends Fragment {
// list contains fragments to instantiate in the viewpager
List<Fragment> fragments = null;
int NUM = 3;
List<String> fragmentTitles = null;
// page adapter between fragment list and view pager
private MyAdapter mPagerAdapter = null;
// view pager
private ViewPager mViewPager;
private Handler handler;
View view;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.main_prova, container, false);
return view;
}
public void clear() {
if (null != mViewPager) {
mViewPager.removeAllViews();
}
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mViewPager = (ViewPager) getView().findViewById(R.id.pager);
fragments = new Vector<Fragment>();
setRetainInstance(true);
fragmentTitles = new Vector<String>();
Bundle scheda = new Bundle();
scheda.putInt("scheda", 0);
// creating fragments and adding to list
fragments.add(Fragment.instantiate(getActivity(),
TempiAtt_Linee.class.getName(), scheda));
fragmentTitles.add(getActivity().getResources().getString(
R.string.urbana_como));
Bundle scheda1 = new Bundle();
scheda1.putInt("scheda", 1);
fragments.add(Fragment.instantiate(getActivity(),
TempiAtt_Linee.class.getName(), scheda1));
fragmentTitles.add(getActivity().getResources().getString(
R.string.extraurbana));
Bundle scheda2 = new Bundle();
scheda2.putInt("scheda", 2);
fragments.add(Fragment.instantiate(getActivity(),
TempiAtt_Linee.class.getName(), scheda2));
fragmentTitles.add(getActivity().getResources().getString(
R.string.urbana_cantu));
View pagerStrip = super.getView().findViewById(R.id.pagerTabStrip);
if (pagerStrip instanceof PagerTabStrip) {
PagerTabStrip pagerTabStrip = (PagerTabStrip) pagerStrip;
pagerTabStrip.setDrawFullUnderline(true);
pagerTabStrip.setTabIndicatorColorResource(R.color.bianco);
} else if (pagerStrip instanceof PagerTitleStrip) {
PagerTitleStrip pagerTitleStrip = (PagerTitleStrip) pagerStrip;
pagerTitleStrip.setTextColor(getResources().getColor(
android.R.color.white));
}
/*
* this.mPagerAdapter = new PagerAdapter(getChildFragmentManager(),
* fragments, fragmentTitles);
* mViewPager.setAdapter(this.mPagerAdapter);
* mViewPager.setCurrentItem(0);
*/
mPagerAdapter = new MyAdapter(getChildFragmentManager());
handler = new Handler();
handler.post(new Runnable() {
#Override
public void run() {
mViewPager.setAdapter(mPagerAdapter);
}
});
mViewPager.setOffscreenPageLimit(2);
}
#Override
public void onDestroyView() {
super.onDestroyView();
onDestroy();
deleteCard();
clear();
view = null;
System.gc();
}
public void deleteCard() {
// Reduce the card counter by one
NUM -= 3;
for (int i = 0; i < fragments.size(); i++) {
fragments.remove(i);
Log.e("SONO IO", fragments.size() + "");
}
mPagerAdapter.notifyDataSetChanged();
}
private class MyAdapter extends FragmentPagerAdapter {
private SparseArray<WeakReference<TempiAtt_Linee>> mPageReferenceMap = new SparseArray<WeakReference<TempiAtt_Linee>>();;
public MyAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int index) {
return getFragment(index);
}
#Override
public int getCount() {
return NUM;
}
public int getItemPosition(Object object) {
return POSITION_NONE;
}
public TempiAtt_Linee getFragment(int key) {
WeakReference<TempiAtt_Linee> weakReference = mPageReferenceMap
.get(key);
if (null != weakReference) {
return (TempiAtt_Linee) weakReference.get();
} else {
return null;
}
}
public Object instantiateItem(ViewGroup container, int position) {
TempiAtt_Linee tempiAttLinee = TempiAtt_Linee.newInstance(position);
mPageReferenceMap.put(Integer.valueOf(position),
new WeakReference<TempiAtt_Linee>(tempiAttLinee));
return super.instantiateItem(container, position);
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
super.destroyItem(container, position, object);
mPageReferenceMap.remove(Integer.valueOf(position));
}
}
}

Resources