How to Hide the Gridview specific positions based on conditions - android

I am passing arraylist, which contains integer values, After checking some conditions I want to hide the previous values present in the arraylist how to achieve this one. If anyone knows please help me to resolve this.

Try this:
View v = gridview.getChildAt(ChildPosition);
v.setVisibility(GONE);

Before the attach the value to the control (setText etc.) in get view method remove that specific position or if you have specific position like you want to hide 5 number position from ArrayList than trying like
here check this condition inside get view method
if(!(position == 5))
{
mTextView.setText(String.values(bean.getValues));
}

final BookingSlotTimeAdapter bookingSlotTimeAdapter = new BookingSlotTimeAdapter(getActivity(), stringArrayList, 1);
moringGridSlot.setAdapter(bookingSlotTimeAdapter);
This way I am passing arraylist to adapter. I am checking current time as a string if current time less than passing arraylist values disable the previous times of the arraylist values.

Related

Cant able to detect which position is clicked in recycler view

I am creating a contact list app using SQL. So I want a OnItemClickListener to detect which item is being clicked and pass it to another activity.
My work is at:
https://github.com/divyank00/ContactList
The error always is NullPointerException.
The problem with your code is that you are putting the position as an Integer Extra in your MainAcitivity, but you are trying to fetch it as a String in contact_details.java which isn't possible. To solve this:
Go to your contact_details.java class, move to Line 59:
//String position=intent.getStringExtra("pos");
//int pos=Integer.parseInt(position);
Replace these lines with this:
int pos = intent.getIntExtra("pos", 0);

How to get certain field from the arrayList object on spinner selection

I just created a spinner and make this spinner read from the database. and display them in the spinner. I already did that. But I want to right down the Id of the selected item.
for example : when I select the first raw called (1, tyat abdullah, sergurey )
I need the Id (1) only to be written down without the full record.
I need the Id (1) only to be written down without the full record.
Then when you are doing labels.add, only put the data you want to see
You can also use doctorsList.get(position) within the selection listener, and set the other text view accordingly.
For example, doctorsList.get(position).getId() seems to get the information you are asking for
simply use this to get the selected item index
int index = spinner.getSelectedItemPosition(); //this will give you the seleected item index
is that what you want ?
leme Know :)

Espresso: How to check if an integer value in a recylerview's child view is greater that 4000

I have a recyclerView in my app. I have 2 fields in it(image_view, price_text_view). The value of price_textview looks like Rs.8000. Now I wanted to keep scrolling until I find an item on the recyclerview whose price is more that Rs.4000(>4000). Can someone please help me with the matcher etc.?
I can't give you whole code here but can give you some logic for implementing this.
this can be done by For loop. And using ArrayList or Array you are passing in your Adapter.
Now lets assume you are passing Arralist to your Adapter say "arrayLst". and from your qustion I assume you are using ArrayList with HashMap.
so your ArraList would be like.
ArrayList<HashMap<String,String>> arrayList = new ArrayList<HashMap<String,String>>();
now do something like this.
for(int i = 0; i<arrayList.size; i++){
if(Integer.valueOf(arraylist.get(i).get("prise_tag")) > 4000){
yourlayoutManager.smoothScrollTo(i);
break;
}
}
I hope this will help you somehow.

Select Checkbox when its Value Equals the String from the EditText field

Problem: In my app, there exists two different ways for a user to add an item to a list: via a TextField and via checking an element in an ExpandableListView. Every time the user enters an item into the TextField, I would like to check if that value appears within any group of the ExpandableListView. If it does, then I would like to check that item.
Implementation of Solution: I have a HashMap that stores as keys all the values within the ExpandableListView, and its values are the corresponding group HashMap in which they are in. If the item is found then I plan to derive its location by using a second HashMap that stores its position within the group.
Question: Using this information, how can I check/uncheck that particular box? Specifically how can I identify a particular child of the ExpandableListView, and then identify a child of that?
Thank you for your time.
My approach is slightly different but it does the work.
Each element of yours must have a HashMap. Considering adding another element to it.
A string element call it ChkVal default value in it is false.
Now when you match the value from textbox to the element in that group. Using the hashmap.
Change its checkbox value.
Boolean b = false;
String chkCondition = hmap.get(chk).toString().toLowerCase();
if (chkCondition.equals("true"))
b = true;
chkBox.setChecked(b);

How to save the state of an item in a listview android

How will i go about saving the state of a listview item during scrolling, so that the recycler does not use it when displaying the next row being. i basically have a listview with 4 textviews and one of the textview is displayed based on a condition, derived from a database. For clarity sake, i will call that dependant textview "A".
my problem is that, simplest case: if "A" is being displayed for only the first item or any other row in the list and its not displayed anywhere else, when scrolling, "A" is displayed on other rows that should not have it. i understand the concept of listview reusing rows, but i can't figure out how to save it on an item, so it doesn't get used in another row. Here is a simplified code with just 2 textview:
holder.viewItemName = (TextView)view.findViewById(R.id.nameId);
holder.viewdescriptionStatus = (TextView)view.findViewById(R.id.viewdescriptionId);
int namecolumn = c.getColumnIndex(DBAdapter.NAME);
String name = c.getString(namecolumn);
holder.viewItemName.setText(name);
int description = c.getColumnIndex(DBAdapter.description);
String descriptionstatus = c.getString(description);
/*problem am having here*/
if(description != null){
holder.viewdescriptionStatus.setText("description available");
holder.viewdescriptionStatus.setTextColor(Color.BLUE);
}
as you can see, am using a viewHolder, but i have come to realise that viewHolder doesn't hold the logic as well. i don't know how to save the state of the holder.viewdescriptionStatus based on that condition. Most of the examples i have seen are based on checkboxes. Please anyone with ideas?.. it will be really appreciated.
P.S : i am using bindView() and newView() since i am using an SQLdatabase and SimpleCursorAdapter. i have the same issue with clicking, but i want to solve the scrolling part first. Thank you for your time.
Try this
holder.viewdescriptionStatus.setText(description != null ? "description available" : "");

Categories

Resources