Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: How to place the dynamically changing arraylist of values into a adapter view in android

user1918566:

MainActivity.java


public static ArrayList feedLayout = new ArrayList();
public static ArrayAdapter pfAdapter;

for(int j=0 ; j strings[j] = jsonArray1.getString(j);
JSONObject promoJsonObject = new JSONObject(strings[j]);
Log.d(TAG,"Promojobj"+promoJsonObject);
FeedPojo.setType(promoJsonObject.getString("type"));
Log.d(TAG, "TypeFeed:" + FeedPojo.getType());
FeedParsePojo.setData(promoJsonObject);
Log.d(TAG,"FeedData"+FeedParsePojo.getData());
FeedPojo feedPojoNews = new FeedPojo(promoJsonObject.getString("id"),
promoJsonObject.getString("businessName"),
promoJsonObject.getString("businessLogoUrl"),
promoJsonObject.getString("text"),
promoJsonObject.getString("photoUrl"),
promoJsonObject.getString("videoUrl"),
promoJsonObject.getString("isNew"));
feedLayout.add(feedPojoNews);
Log.d(TAG,"ListOfValues"+feedLayout);
}

FeedAdapter.java


public class PromotionFeedAdapter extends ArrayAdapter {

public int layout;
Button getCal;
WebView display;
public static String MY_PREFS_NAME="my_prefs";
private static final String TAG = PlatformHttp.class.getSimpleName();
Context mContext;


public PromotionFeedAdapter(Context context, int resource, List objects) {
super(context, resource, objects);
layout=resource;
}

@Override
public View getView(final int position, View convertView, final ViewGroup parent){


//ViewHolder2 mainViewHolder = null;

mContext = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(getContext());
convertView= inflater.inflate(layout,parent,false);


// Layout Folder For Promotion

ViewHolder viewHolder = new ViewHolder();

viewHolder.title = (TextView) convertView.findViewById(R.id.pf_title);
viewHolder.category = (TextView) convertView.findViewById(R.id.pf_category);
viewHolder.picture = (ImageView) convertView.findViewById(R.id.pf_main_pic);
viewHolder.brand = (TextView) convertView.findViewById(R.id.pf_type);


// Navigation listner onClick Promotion

viewHolder.title.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getContext().startActivity(new Intent(getContext(),Webview.class));
}
});


convertView.setTag(viewHolder);
TextView title = ((ViewHolder)convertView.getTag()).title;
TextView category = ((ViewHolder) convertView.getTag()).category;
TextView brand = ((ViewHolder) convertView.getTag()).brand;
title.setText(getItem(position));
category.setText(getItem(position));
brand.setText(getItem(position));

String picUrl;

picUrl=PromotionsFeedActivity.Pictures.get(position);
convertView.setTag(viewHolder);
URL newurl = null;
try {
newurl = new URL(picUrl);
Picasso.with(getContext()).load(picUrl).into(viewHolder.picture);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return convertView;
}

public static class ViewHolder {
TextView title;
TextView brand;
ImageView picture;
TextView category;
}

In MainActivity class I have added values into the ArrayList(feedLayout). I want those values to be placed in the adapter view. In each array list of object there were values stored in it and I want them to be get and displayed on the adapter view.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: How to place the dynamically changing arraylist of values into a adapter view in android

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×