last day (14 days later) » 

5:22 AM
0
Q: How to Set data into spinner using Recycler VIEW

Puja SinghIn my code i have RecyclerView.I am setting id and name into text view. private List<Listitem> itemList; private Context context; //For Spinner private String[] items = new String[itemList.size()]; private ArrayAdapter<String> spinnerArrayAdapter; public ListItemAdapter(Context context, List<

 
getting null pointer Exception here private String[] items = new String[itemList.size()]; I just want to put Price TextView into Spinner.
 
Initialize items = new String[itemList.size()]; in ListItemAdapter constructor after this.itemList = itemList;
@PujaSingh Did u pass String[] in your constructor too ?
 
yes i m trying private String[] items = new String[itemList.size()]; public ListItemAdapter(Context context, List<Listitem> itemList,String[] str) { this.items= str;
 
No. This is wrong what are you r doing. Read my above comment. Still u have doubt ask me
 
As u edited below as itis i put there so it gives exception.
 
5:22 AM
No
 
plzz write that constructor
 
public ListItemAdapter(Context context, List<Listitem> itemList) {
this.context = context;
this.itemList = itemList;
// this.items = items;

}
this is ur constructor
ok?
 
yes
 
Now Declared variable String[] myList; in declaration part
Ok ?
 
yup
 
5:24 AM
public ListItemAdapter(Context context, List<Listitem> itemList) {
this.context = context;
this.itemList = itemList;
this.myList = new String[itemList.size()];

}
Now initialize it as i did above
in constructor
U got it ? Or still any doubt?
 
hahahah
 
What happen ? Still same ?
 
In my main Ativity
 
Ok so in that u r passing a null arraylist
 
I declared this
private String[] items=new String[]{};
adapter = new ListItemAdapter(getApplicationContext(), dataArrayList);
getting error here
yes
I want to pass price Into spinner
 
5:28 AM
Oh ok I got it
Ok so u can pass now from adapter class
 
Yes
 
ArrayAdapter<String> adapter = new ArrayAdapter().....
something like
 
Yes This is for Only price
 
U means its showing only only price though u have many price
 
Chk my POJO class
 
5:31 AM
OK
 
private List<Listitem> itemList; here I m successfully getting 8 items
 
so don't need to do this
for (int i = 0; i < itemList.size(); i++) {
items[i] = itemList.get(position).getProducts_regular_price();
holder.price.setText(items[i]);
 
In itemlist
 
Because in spinner adapter u'r passing items list
Ok I Got
 
Plesse help me
 
5:32 AM
I understood the issue
Listitem class u have a price
var
in that u r getting 8 Items means 8 prices will be there
Now u differentiate price and show in spinner
 
I just want Price into spinner ? How Do I hold That price
 
U can make custom adapter class and pass into that adapter class for Spinner
and set price for TextView
spinnerArrayAdapter = new ArrayAdapter<String>(context, R.layout.spinner, items);
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner);
holder.spinner1.setAdapter(spinnerArrayAdapter);

// String spinnerPos = spinnerArrayAdapter.getPosition (itemList.get());


for (int i = 0; i < itemList.size(); i++) {
items[i] = itemList.get(position).getProducts_regular_price();
holder.price.setText(items[i]);
this code will be interchanged]
 
public static final String BASE_URL= "http://www.grocerybroz.com";
public static final String FETCH_ITEM = "/json4.txt";
 
because spinnerArrayAdapter = new ArrayAdapter<String>(context, R.layout.spinner, items); here items will gives you all data for ListItem list
 
pleses go to this link
I just want price into spinner
 
5:37 AM
items[i] what this gives you? Did u check in Log/
 
there was null pointer exception above so chk nahi kar pa rahi thi
let me chk
 
for (int i = 0; i < itemList.size(); i++) {
items[i] = itemList.get(i).getProducts_regular_price();
First do this
print this in Log
items[i]
and tell me the value for it
 
okay
can i send u my project.If poss to chk
 
Yes U can
 
your id ?
 
5:41 AM
U can get it from my SO profile
 
okay
 
When u send me just let me know
:)
@PujaSingh sent??
 
I sent
 
Ok let me check
 
via this
you Got that
 
5:49 AM
Ok np
Till then telling you u r doing a silly mistake in ur code
Yes I got
 
Yes I know I alz did that mistake.I jst have 3 month exp in Android
 
@PujaSingh Is that ur Id?
 
Yes
was aditisingh
:)
 
Yes ! So asked !
@PujaSingh Ok so u just started android
 
Yup
 
5:52 AM
Ok Np
 
And now I m live project
Np?
 
No Problem :)
 
Please chk it .And revert me back
 
Yes downloading now
and AS updating
 
I got Value in text view
But Not In spinner text
I want it there
 
5:55 AM
I know
why
because u r using custom layout
so
 
Ri8
 
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, items);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(dataAdapter);
U need to use that
If u want to custom layout then use custom adapter class
 
Okay
 
@PujaSingh Also drop me msg on hangout so i can do from mobile easliy
 
yup
Your number?
 
5:59 AM
Wait I am mailing you
 
okay
u did changes on that
 
No downloading still
net is too slow
so
mail sent
@PujaSingh
 
okay let me chk
 
ok
I m going for tea break so just stay in touch on that. Ping me there
 
ya sure me tooo
Thanks for ur time
 
6:08 AM
Np. Wel come ! Got my mail ? I was waiting for ur reply. Now I Am going
 
Wait. First I solve ur issue then go
 
hahaha
 
Yes till then i don't like
 
What u changed on tht?
 
6:16 AM
just a minute remaining
I need to change first
because downloading the code
Internet getting slow
 
okay
 
@PujaSingh did u send me msg there? So i just confirm it
 
where?
 
I sent u my number. So did u send me a msg
 
i dint get any mail
 
6:20 AM
Are you sure?
 
yes
 
ok i m posting here number but note down quicky
 
I got one mail only from 11:00
okay
 
quick
Okay Np !!
done ?
 
yes
 
6:22 AM
Noted down ?
 
yup
i jst rang u
 
Ok i am waiting
@PujaSingh sent ?
 
hey was that ur number?
I jst called
 
Okay Np !
Noted now?
 
give me conferm
u got ring
 
6:33 AM
yes got it
start from 88
 
yup
218 at d end
 
Yes
 
I pinged u
on whtsapp
 
That was ur real name in mail?
 
chkd it
 
6:36 AM
ok
 
no puja is my name
 
Oh ok np
 
6:57 AM
@PujaSingh got mail?
 
7:40 AM
yup cheking
is that working coad
?
 
8:05 AM
@PujaSingh There ??
 

last day (14 days later) »