Base Adapter onclick not working - android

I am trying to use the material dialogs library Material Dialog and i can't get the callback to work for the custom adapter.
The items are displayed perfectly but on click of the items i don't get any callback.
Base Adapter
public class EcardBaseAdapter extends BaseAdapter implements View.OnClickListener {
private LayoutInflater mInflater;
private List<? super Greeting> items;
private Context context;
private final int width;
private final int height;
public EcardBaseAdapter(List<Greeting> items, Context context) {
this.context = context;
mInflater = LayoutInflater.from(context);
this.items = items;
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
this.width = metrics.widthPixels;
this.height = metrics.heightPixels;
}
#Override
public int getCount() {
return items.size();
}
#Override
public Object getItem(int i) {
return items.get(i);
}
#Override
public long getItemId(int i) {
return i;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
ViewHolder holder;
if (convertView == null) {
view = mInflater.inflate(R.layout.custom_item, parent, false);
holder = new ViewHolder();
holder.avatar = (ImageView) view.findViewById(R.id.image_path);
holder.name = (TextView) view.findViewById(R.id.custom_event_name);
view.setTag(holder);
} else {
view = convertView;
holder = (ViewHolder) view.getTag();
}
if (items.get(position) instanceof ECard) {
ECard eCard = (ECard) items.get(position);
Log.i("test", eCard.getImage() + " " + eCard.getSubject());
if (eCard.getImage() != null) {
Glide.with(context)
.load(eCard.getImage())
.fitCenter()
.override(width, height / 2)
.into(holder.avatar);
//holder.avatar.setImageURI(Uri.parse(eCard.getImage()));
}
holder.name.setTextColor(ContextCompat.getColor(context, R.color.darkGrey));
holder.name.setText(eCard.getSubject());
}
return view;
}
#Override
public void onClick(View view) {
Log.i("click", "itemclick");
}
private class ViewHolder {
public ImageView avatar;
public TextView name;
}
}
Code in the activity which uses the adapter
new MaterialDialog.Builder(birthday_details.this)
.title("Ecard")
.adapter(adapter,
new MaterialDialog.ListCallback() {
#Override
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
Toast.makeText(birthday_details.this, "Clicked item " + which, Toast.LENGTH_SHORT).show();
}
})
.show();

I did not understandd all your code, but I seems you never call
view.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i("click", "itemclick");
}
};
or in your case
view.setOnClickListener(this);

Related

Android custom listadapter always deleting the last item

Good day,
I am trying to refresh my knowledge in android programming
by creating a simple memo app with custom adapter list.
My problem is, even I call "NotifyDataSetChanged();",
the value deleted in my list is always the last one.
Though when I refresh it, it will display the correct one.
Here is my code :
public class CustomAdapter extends BaseAdapter{
List<Memo> memos;
Context context;
int [] imageId;
private static LayoutInflater inflater = null;
public CustomAdapter(MainActivity mainActivity, List<Memo> _memos) {
memos = _memos;
context = mainActivity;
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return memos.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
public class Holder
{
TextView tv;
TextView tv2;
Button deleteMemoBtn;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
Holder mViewHolder = null;
if (convertView == null) {
mViewHolder = new Holder();
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.list_memo, parent, false);
mViewHolder.tv = (TextView) convertView.findViewById(R.id.textView1);
mViewHolder.tv2 = (TextView) convertView.findViewById(R.id.textView2);
mViewHolder.deleteMemoBtn = (Button) convertView.findViewById(R.id.deleteMemoBtn);
mViewHolder.tv.setText(memos.get(position).getMemoTitle());
mViewHolder.tv2.setText(Integer.toString(memos.get(position).getMemoID()));
mViewHolder.tv.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "You Clicked " + memos.get(position).getMemoTitle(), Toast.LENGTH_LONG).show();
}
});
mViewHolder.deleteMemoBtn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "deleted " + Integer.toString(position), Toast.LENGTH_LONG).show();
memos.remove(position);
notifyDataSetChanged();
}
});
}
return convertView;
}
}
Hoping someone can lighten me up why this code is not working.
Thank you!
Try this code.
public class CustomAdapter extends BaseAdapter {
List<Memo> memos;
Context context;
int[] imageId;
private LayoutInflater inflater = null;
public CustomAdapter(Context mainActivity, List<Memo> _memos) {
memos = _memos;
context = mainActivity;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return memos.size();
}
#Override
public Object getItem(int position) {
return memos.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
public class Holder {
TextView tv;
TextView tv2;
Button deleteMemoBtn;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
Holder mViewHolder = null;
if (convertView == null) {
mViewHolder = new Holder();
convertView = inflater.inflate(R.layout.list_memo, parent, false);
mViewHolder.tv = (TextView) convertView.findViewById(R.id.textView1);
mViewHolder.tv2 = (TextView) convertView.findViewById(R.id.textView2);
mViewHolder.deleteMemoBtn = (Button) convertView.findViewById(R.id.deleteMemoBtn);
convertView.setTag(mViewHolder);
} else {
mViewHolder = (Holder) convertView.getTag();
}
mViewHolder.tv.setText(memos.get(position).getMemoTitle());
mViewHolder.tv2.setText(Integer.toString(memos.get(position).getMemoID()));
mViewHolder.tv.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "You Clicked " + memos.get(position).getMemoTitle(), Toast.LENGTH_LONG).show();
}
});
mViewHolder.deleteMemoBtn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "deleted " + Integer.toString(position), Toast.LENGTH_LONG).show();
memos.remove(position);
notifyDataSetChanged();
}
});
return convertView;
}
}

Ratingbar in listview

Rating bar is resets when we scroll down in android, I need to send the response of rating feedback to server but it will resets or not saved when i scroll down in listview in android.
public class FacultyListAdapter extends BaseAdapter {
private final Context context;
public FacultyListAdapter(Context context) {
this.context = context;
if (!facultylist.isEmpty())
courseEmptyLayout.setVisibility(LinearLayout.GONE);
}
#Override
public View getView(final int position, View convertView,
ViewGroup parent) {
final ViewHolder TabviewHolder;
if (convertView == null) {
TabviewHolder = new ViewHolder();
LayoutInflater inflater = getLayoutInflater();
convertView = inflater.inflate(R.layout.list_item_feedback,
parent, false);
TabviewHolder.FacultyName = (TextView) convertView.findViewById(R.id.FacultyName);//facultyname
TabviewHolder.rating = (RatingBar) convertView.findViewById(R.id.rating);//rating starts
TabviewHolder.Submit = (Button) convertView.findViewById(R.id.btnSubmit);
// Save the holder with the view
convertView.setTag(TabviewHolder);
} else {
TabviewHolder = (ViewHolder) convertView.getTag();
}
final Faculty mFac = facultylist.get(position);//*****************************NOTICE
TabviewHolder.FacultyName.setText(mFac.getEmployeename());
TabviewHolder.rating.setTag(position);
TabviewHolder.rating.setRating(mFac.getRatingStar());
// TabviewHolder.ModuleName.setText(mFac.getSubject());
TabviewHolder.rating.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
feedbackresult =String.valueOf(rating);
TabviewHolder.rating.setRating(Float.parseFloat(feedbackresult));
Log.d("feedback","feedback is: "+ feedbackresult);
}
});
return convertView;
}
/*private RatingBar.OnRatingBarChangeListener onRatingChangedListener(final ViewHolder holder, final int position) {
return new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float v, boolean b) {
FacultyName item = getItem(position);
item.setRatingStar(v);
Log.i("Adapter", "star: " + v);
}
};
}*/
#Override
public int getCount() {
return facultylist.size();
}
#Override
public Object getItem(int position) {return facultylist.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
}
Listview and recyclerview auto refresh (recreate) view based on your list passed to it when you scroll.
You have to store your rating to your List<> (i think it is facultylist) in which you contains all details.
When user click on rating you need to store rating to particular index. Then your listview show correct rating based on value in list.
refer this link Rating Bar in ListView Android
public class FeedbackAdapter extends BaseAdapter {
static Context context;
List<FeedbackRowDetails> row;
ViewHolder holder;
public FeedbackAdapter(Context context,List<FeedbackRowDetails> row)
{
this.context = context;
this.row =row;
}
private class ViewHolder {
TextView tv_slno, tv_productname, tv_time;
RatingBar rb_productrating;
}
#Override
public View getView( final int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.custom_feedback_row_format,parent, false);
holder = new ViewHolder();
holder.tv_slno = (TextView) convertView.findViewById(R.id.tv_slno);
holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
holder.tv_productname = (TextView) convertView.findViewById(R.id.tv_productname);
holder.rb_productrating=(RatingBar) convertView.findViewById(R.id.rb_productrating);
convertView.setTag(holder);
} else
{
holder = (ViewHolder) convertView.getTag();
}
holder.rb_productrating.setOnRatingBarChangeListener(onRatingChangedListener(holder, position));
holder.rb_productrating.setTag(position);
holder.tv_slno.setText(String.valueOf(position + 1));
holder.tv_time.setText(getItem(position).gettime());
holder.tv_productname.setText(getItem(position).getproductsName());
float rating=Float.valueOf(getItem(position).getrating());
holder.rb_productrating.setRating(rating);
return convertView;
}
private RatingBar.OnRatingBarChangeListener onRatingChangedListener(final ViewHolder holder, final int position)
{
return new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean b)
{
FeedbackRowDetails item = row.get(position);
int roundoff_rating = (int)Math.round(rating);
ratingBar.setRating(roundoff_rating);
item.setrating(String.valueOf(roundoff_rating));
}
};
}
#Override
public int getCount() {
return row.size();
}
#Override
public FeedbackRowDetails getItem(int position)
{
return row.get(position);
}
#Override
public long getItemId(int position) {
return row.indexOf(getItem(position));
}
}

Ratingbar's rating within listview resets

Senario: To get rating feedback for multiple multiple products.
Problem: Ratingbar value resets on scrolling listview by calling setOnRatingBarChangeListener
Expected output:
Customized listview adpater code:
public class FeedbackAdapter extends BaseAdapter {
static Context context;
List<FeedbackRowDetails> row;
ViewHolder holder;
public FeedbackAdapter(Context context,List<FeedbackRowDetails> row)
{
this.context = context;
this.row =row;
}
private class ViewHolder {
TextView tv_slno, tv_productname, tv_time;
RatingBar rb_productrating;
}
#Override
public View getView( final int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.custom_feedback_row_format,null);
holder = new ViewHolder();
holder.tv_slno = (TextView) convertView.findViewById(R.id.tv_slno);
holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
holder.tv_productname = (TextView) convertView.findViewById(R.id.tv_productname);
holder.rb_productrating=(RatingBar) convertView.findViewById(R.id.rb_productrating);
convertView.setTag(holder);
} else
{
holder = (ViewHolder) convertView.getTag();
}
FeedbackRowDetails row_pos = row.get(position);
holder.tv_slno.setText(String.valueOf(position + 1));
holder.tv_time.setText(row_pos.gettime());
holder.tv_productname.setText(row_pos.getproductsName());
holder.rb_productrating.setRating(Float.valueOf(row_pos.getrating()));
holder.rb_productrating.setOnRatingBarChangeListener(new OnRatingBarChangeListener()
{
public void onRatingChanged(RatingBar ratingBar, float rating,boolean fromUser)
{
FeedbackRowDetails row_pos = row.get(position);
int roundoff_rating = (int)Math.round(rating);
ratingBar.setRating(roundoff_rating);
row_pos.setrating(String.valueOf(roundoff_rating));
}
});
return convertView;
}
#Override
public int getCount() {
return row.size();
}
#Override
public Object getItem(int position) {
return row.get(position);
}
#Override
public long getItemId(int position) {
return row.indexOf(getItem(position));
}
}
Just wrap your codes present inside your onRatingChanged method with a simple if as shown below
if(fromUser) {
FeedbackRowDetails row_pos = row.get(position);
int roundoff_rating = (int) Math.round(rating);
ratingBar.setRating(roundoff_rating);
row_pos.setRating(String.valueOf(roundoff_rating));
}
Have tested it with emulator and it was working as expected. Hope this solves your problem
This problem solved with reference to link
public class FeedbackAdapter extends BaseAdapter {
static Context context;
List<FeedbackRowDetails> row;
ViewHolder holder;
public FeedbackAdapter(Context context,List<FeedbackRowDetails> row)
{
this.context = context;
this.row =row;
}
private class ViewHolder {
TextView tv_slno, tv_productname, tv_time;
RatingBar rb_productrating;
}
#Override
public View getView( final int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.custom_feedback_row_format,parent, false);
holder = new ViewHolder();
holder.tv_slno = (TextView) convertView.findViewById(R.id.tv_slno);
holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
holder.tv_productname = (TextView) convertView.findViewById(R.id.tv_productname);
holder.rb_productrating=(RatingBar) convertView.findViewById(R.id.rb_productrating);
convertView.setTag(holder);
} else
{
holder = (ViewHolder) convertView.getTag();
}
holder.rb_productrating.setOnRatingBarChangeListener(onRatingChangedListener(holder, position));
holder.rb_productrating.setTag(position);
holder.tv_slno.setText(String.valueOf(position + 1));
holder.tv_time.setText(getItem(position).gettime());
holder.tv_productname.setText(getItem(position).getproductsName());
float rating=Float.valueOf(getItem(position).getrating());
holder.rb_productrating.setRating(rating);
return convertView;
}
private RatingBar.OnRatingBarChangeListener onRatingChangedListener(final ViewHolder holder, final int position)
{
return new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean b)
{
FeedbackRowDetails item = row.get(position);
int roundoff_rating = (int)Math.round(rating);
ratingBar.setRating(roundoff_rating);
item.setrating(String.valueOf(roundoff_rating));
}
};
}
#Override
public int getCount() {
return row.size();
}
#Override
public FeedbackRowDetails getItem(int position)
{
return row.get(position);
}
#Override
public long getItemId(int position) {
return row.indexOf(getItem(position));
}
}

How to change listview DataSet on Gallery drag?

I have a gallery with custom views that represent categories, depending on which category of the gallery is selected the listview should display one dataset or another, it is working, but the dataset shown does not correspond with the category selected,
Here is the adapter for the gallery:
public class GalleryViewAdapter extends BaseAdapter {
private Context mContext;
private ArrayList<TreeNode> mNodes;
private HomeFragment mFrag;
private ListView mList;
public GalleryViewAdapter(Context c, ArrayList<TreeNode> mNodes, HomeFragment mFrag, ListView galleryList) {
mContext = c;
this.mNodes = mNodes;
this.mFrag = mFrag;
mList = galleryList;
}
#Override
public int getCount() {
return mNodes.size();
}
#Override
public Object getItem(int position) {
return mNodes.get(position);
}
#Override
public long getItemId(int position) {
TreeNode childNode = (TreeNode) mNodes.get(position);
if (childNode.getReference() instanceof Categoria) {
return Long.valueOf(((Categoria) mNodes.get(position).getReference()).idCat);
} else {
return Long.valueOf(((Contenido) mNodes.get(position).getReference()).idCon);
}
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
final TreeNode childNode = (TreeNode) mNodes.get(position);
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
int screenWidth = wm.getDefaultDisplay().getWidth();
if (childNode.getReference() instanceof Categoria) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.fragment_gallery_item, parent, false);
}
ImageView imageView = (ImageView) convertView.findViewById(R.id.fragment_gallery_item_imageview);
TextView mTextView = (TextView) convertView.findViewById(R.id.fragment_gallery_item_textView);
Categoria mCat = (Categoria) childNode.getReference();
imageView.setImageBitmap(Tools.scaleImageInPixels(Tools.createBitmapFromBase64(mCat.icon64.getBytes()),
screenWidth));
mTextView.setText(mCat.nombreCat);
int newHeight = mFrag.getActivity().getWindowManager().getDefaultDisplay().getHeight() / 4;
int orgWidth = imageView.getDrawable().getIntrinsicWidth();
int orgHeight = imageView.getDrawable().getIntrinsicHeight();
int newWidth = ((int) Math.floor((orgWidth * newHeight) / orgHeight) / 2);
imageView.setMaxHeight(newHeight);
imageView.setMaxWidth(newWidth);
GalleryListAdapter mListAdapter = new GalleryListAdapter(mFrag.getActivity(), childNode, mFrag);
mList.setAdapter(mListAdapter);
} else {
}
return convertView;
}
}
And here is my galleryListViewAdapter
public class GalleryListAdapter extends BaseAdapter {
private Context mContext;
private TreeNode mNode;
private HomeFragment mFrag;
public GalleryListAdapter(Context mContext, TreeNode mNode, HomeFragment mFrag) {
this.mContext = mContext;
this.mNode = mNode;
this.mFrag = mFrag;
}
#Override
public int getCount() {
return mNode.getChildren().size();
}
#Override
public Object getItem(int position) {
return mNode.getChildren().get(position);
}
#Override
public long getItemId(int position) {
if (mNode.getReference() instanceof Categoria) {
return Long.valueOf(((Categoria) mNode.getReference()).idCat);
} else {
return Long.valueOf(((Contenido) mNode.getReference()).idCon);
}
}
#Override
public boolean hasStableIds() {
return true;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (mNode.getReference() instanceof Categoria) {
mNode = (TreeNode) mNode.getChildren().get(position);
}
if (rowView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.fragment_list_carrousel_item, parent, false);
}
TextView autorView = (TextView) rowView.findViewById(R.id.firstLine);
TextView textView = (TextView) rowView.findViewById(R.id.secondLine);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
Contenido mCon = (Contenido) mNode.getReference();
autorView.setText(mCon.tituloCon);
textView.setText("");
imageView.setImageBitmap(Tools.scaleImage(Tools.getParentIconRecursive(mNode),
(int) MainActivity.getInstance().getAttributeDimension(R.attr.listPreferredItemHeight)));
int newHeight = mFrag.getActivity().getWindowManager().getDefaultDisplay().getHeight() / 2;
int orgWidth = imageView.getDrawable().getIntrinsicWidth();
int orgHeight = imageView.getDrawable().getIntrinsicHeight();
int newWidth = ((int) Math.floor((orgWidth * newHeight) / orgHeight) / 2);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
newWidth, newHeight);
imageView.setLayoutParams(params);
rowView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mFrag.goToNode(mNode);
}
});
return rowView;
}
}
Thank you very much!
You have to set an OnItemSelectedListener on your Gallery like this:
private Gallery.OnItemSelectedListener _scrollListener = new Gallery.OnItemSelectedListener()
{
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id){
//execute the method that refresh the listview
fillListView(position);
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
}
};

Android - Pull to refresh on custom adapter

I'm developing an Android Application and I have a custom adapter for my ListView. I want to use a Pull to refresh library, such as this one. This works fine with an ArrayAdapter, but not with a custom adapter.
How can I get my pull to refresh working with a custom adapter?
Here my adapter code:
public class AdvertListAdapter extends BaseAdapter {
private AdvertListActivity activity;
private int currentFirstVisibleItem=0;
private int currentLastVisibleItem=8;
public AdvertListAdapter(AdvertListActivity activity) {
this.activity = activity;
}
public void setFirstVisibleItem(int currentFirstVisibleItem) {
this.currentFirstVisibleItem=currentFirstVisibleItem;
}
public void setLastVisibleItem(int currentLastVisibleItem) {
this.currentLastVisibleItem=currentLastVisibleItem;
}
#Override
public int getCount() {
return activity.getAdvertList().size();
}
#Override
public Advert getItem(int pos) {
return activity.getAdvertList().get(pos);
}
#Override
public long getItemId(int pos) {
return activity.getAdvertList().get(pos).getId();
}
private class ViewHolder {
public ImageView image;
public TextView title;
public TextView price;
public TextView size;
public TextView city;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder view;
LayoutInflater inflator = activity.getLayoutInflater();
if(convertView == null) {
view = new ViewHolder();
convertView = inflator.inflate(R.layout.listview_advertlist, null);
view.image = (ImageView) convertView.findViewById(R.id.advertImage);
view.title = (TextView) convertView.findViewById(R.id.advertTitleText);
view.price = (TextView) convertView.findViewById(R.id.advertPriceText);
view.size = (TextView) convertView.findViewById(R.id.advertSizeText);
view.city = (TextView) convertView.findViewById(R.id.advertCityText);
convertView.setTag(view);
}else {
view = (ViewHolder) convertView.getTag();
}
Advert advert = activity.getAdvertList().get(position);
view.title.setText(advert.getTitle());
view.price.setText(String.valueOf(advert.getPrice()+"€"));
view.size.setText("Taille: "+advert.getSize());
view.city.setText(advert.getCity());
if(position <= currentFirstVisibleItem || position >= currentLastVisibleItem) {
view.image.setImageResource(R.drawable.defaultadvertimage);
ServiceHelper.loadAsyncImage(view.image, activity.getApplicationContext(), String.valueOf(advert.getId()+"-mini"), "advert");
}
return convertView;
}
}
Here my activity code:
list = (PullToRefreshListView) findViewById(R.id.advertList);
advertList = getAdvertList();
((PullToRefreshListView) list).setOnRefreshListener(new OnRefreshListener() {
#Override
public void onRefresh() {
// Do work to refresh the list here.
new GetDataTask().execute();
}
});
list.setAdapter(adapter);

Categories

Resources