Getting particular view from expandable listview - java

In my list view I have an textview in expandable group and I want to open the dialog when textview is clicked to fill the information through edittext and update textview.
Problem: how could I get the groupview textview item in my fragment oncreateview() method.

You shouldn't pass your view item form a fragment to an other. You should retrieve the object associated with your group view, pass this object to your second/edition fragment. You can use
setTargetFragment(...) and onActivityResult(...) to send the modified text from your second to your first fragment. And then you can update you list of object and refresh your expandableListView to display the updated text.
If you need help doing this please post your code.

Related

Android. How to show 2 items in recycler view and then add one item on every button click

I want to show 2 items by default and add items in recycler view when we click button in main activity. Those item contains edittext so I have to get the data from edittext in my main activity.
Basically you have to create two different ViewType/Layouts to implement this.
Sharing related links below..
https://www.geeksforgeeks.org/how-to-create-recyclerview-with-multiple-viewtype-in-android/
How to create RecyclerView with multiple view types
For adding items to Recycler view when you click in a button you should add the item in the list and notify adapter that new item added at the end of the recyclerview using notifyItemInserted()
and for the other question for getting the edittext value from the adapter to the activity you can create a callback interface that implemented in the activity and pass the reference to the adapter and fire it from adapter when Edittext value is changed

How recycler view Data bind?

How Recycler view Bind Data One By One or All in one time?
void onBindViewHolder (VH holder,int position,List<Object> payloads)
Called by RecyclerView to display the data at the specified position.
This method should update the contents of the itemView to reflect the
item at the given position.
So one by one. More here .
Your recycler view calls RecyclerView.Adapter when you set adapter to recycler view or
notify dataset changes to the adapter.
Recycler view calls OnBindViewHolder for each item in your recycler.
Hence, recyclerview binds data one by one.
You can clearly see this when you implement animation to the recycler view items.
RecyclerView is a list drawing library that essentially provides a fixed-size window to load a large dataset into. It recycles the views it created at the begining when the views go out of scope (window) and then if there is a need, reuses them to make it seem as if the views were never offloaded and were virtually present outside the window.It binds the rows which are visible to you and recycles the rest

Array list adapter with button objects

I am new to android app development.i want to create a list view that has only one button per cell of list view.For the adapter of this list view i need to give 'ArrayList' as parameter so that I can add and update list view whenever I need.
Take a look at this tutorial for custom listView.
You can put the button or anything you want in rowlayout.xml

Adding another line of components to relativelayout

Anyone know how to get this result?
Description:
When the '+' button is clicked, another line of EditText, Spinner, EditText and Button will be displayed below the line. And lines go on adding if the user click on the '+' button.
Thanks!
I think the best would be to implement a custom ViewGroup extending a LinearLayout in vertical orientation.
You'll register an OnClickListener on the last button: if the row is the last in the list, you'll inflate a new ingredients_item.xml and add it to your view (also you'll refresh the drawable from + to -), otherwise remove the current row.
Your custom view will provide a method like List<Ingredient> getIngredients(), so you'll be able to pass this list to some save() method.
I pushed the demo on GitHub

Calling Button from different view in Android

In my app I have 3 radiobuttons on top of the view. When i choose one the 'body' underneath that changes to the XML-view i defined.
(If you want more information + pics, I asked a question about this earlier: Dynamically change view inside view in Android)
Now i want to call and change the text of the buttons and edittext's from the different views.
When I do btnAutopech = (Button) findViewById(R.id.btnAutopech); it's gives an NullPointerException.
How can I do this?
Try this.......
LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll= new LinearLayout(context);
ll=(LinearLayout)layoutInflater.inflate(R.layout.gegevens_verzekeringen, ll);
btnAutopech = (Button) ll.findViewById(R.id.btnAutopech);
Thanks.........
Depends on how you solved the last question you linked to. If your inflating new views into the area you want to change then you won't be able to retreive a reference to them using finViewById. I.e. they don't actually exist.
When you re-display your view, within which you want to display text based, on your other views outcome, you would have to re-assign the text when you re-attach/display your view. You could then assign text from a member variable of the class, or perhaps from sharedPreferences or a contentProvider.
EIther way, this sort of all depends on how you've solved the issue of your original question and when you attach/remove your views.
To summerise:
It looks like your removing your other views when you visit other views, so store your data in a member variable that persists.
attach view A
got to view B
Click button or something in view B and update member variable used by view A
Go to view A (Removing view B and attaching view A)
set text on view A from member variable (updated as a result of clicking button in view B for example)

Categories

Resources