last day (14 days later) » 

11:30
0
A: How to pass multiple string to extend adapter and to the layout ..?

Ankitkumar MakwanaYou are currently using ArrayList<String> items so you can only pass single String by it. Need to change that items list with custom Pojo list like Refrence link POJO public class DepartmentData { private int id; private String deptname; private String date; private String name; private String m...

in the near items.add(title); android studio asking me to change Change variable 'items' type to 'java.util.ArrayList<java.lang.String>
have first create Pojo class wich string you needed ?
Ya.. Please see the updates.. what should i do now ?
create list like ArrayList<NewsData> items = new ArrayList<NewsData>();
NewsData objNewsData = new NewsData(); create
fill values by set objNewsData.setTitle("Your title");
after that add in items.add( objNewsData) then pass that list to adpater
Hae one more thing how to extract or get the title in NewsAdapter ?
11:30
now you need listobject with position
NewsData objNewsData = items.get(position);
String title = objNewsData.getTitle();
ok wait
Also Pls accept my ans to.
if its works
what about this line txtTitle.setText(items.get(position)); no need ah ?
setText ?
no need now you create new object as like above mentioned
NewsData objNewsData = items.get(position);
String title = objNewsData.getTitle();
txtTitle.setText(title);
like that
using that objNewsData you can get all types of data which mentioned in that class
Ya .. got it.. but it's repeat one item 10 times .. it's may be my api broked
then i'm gonna accept your answer .. man you are a life saver ..
11:40
no you need to fill proper list
pls check your fill list
and pass all time unique position to get
07-07 09:38:52.529 27923-27923/com.newstime.simon.newstime D/NEWSADAPTER﹕ News adapter messages[com.newstime.simon.newstime.NewsData@871576a, com.newstime.simon.newstime.NewsData@871576a, com.newstime.simon.newstime.NewsData@871576a, com.newstime.simon.newstime.NewsData@871576a, com.newstime.simon.newstime.NewsData@871576a, com.newstime.simon.newstime.NewsData@871576a, com.newstime.simon.newstime.NewsData@871576a]
it's weird right ?
is that right this program ....
ArrayList<NewsData> items = new ArrayList<NewsData>();

try {
JSONArray reader = new JSONArray(message);
NewsData objNewsData = new NewsData();

for (int i=0; i< reader.length(); i++) {
JSONObject object = reader.getJSONObject(i);
String title = object.getString("title");
String content = object.getString("description");

objNewsData.setTitle(title);
objNewsData.setContent(content);
items.add(objNewsData);
one thing is wrong here
Put
in side for loop
NewsData objNewsData = new NewsData();
@Rosini get it ?
ya.. it's coming.. thanks for your valuable time...
wc accept my ans
ok .. did
11:46
thanks

last day (14 days later) »