I am working on a project and I was wondering how can I implement like button(custom) in list view.
it should append likes for the particular row whenever like button is pressed and unlike it if pressed for second time.just like face book.
can anyone provide me link to such tutorial??
I also want to know how to handle back end part..
please suggest something.
thank you.
In your custom adapter's getView() you need to add a method as setOnClickListener() for the buttons you're using.
Any data associated with the button has to be added with myButton.setTag() in the getView() and can be accessed in the onClickListener via view.getTag()
Related
I'd like to change my listView items dynamically. The algorithm goes like this:
1.I create the default view for my listView using adapter and show it to user. The list item contains Imageview, textview and another imageview which is invisible.
2.The data is beeing dowloaded in the meantime.
3. after my data is downloaded, I'd like to check whether my listview contains any of downloaded items. If yes, I want to make visible the previously invisible ImageView for this item.
Should I add some kind of method to my adapter, call it and then call invalidateViews(), notifyDataSetChanged(), or notifyDataSetInvalidated()? Or maybe there is some kind of standard way to find my adapter's item by Id or sth and then make visible the imageview for this item?
This list update operation is the only one left to implement for me.
Should I add some kind of method to my adapter, call it and then call invalidateViews(), notifyDataSetChanged(), or notifyDataSetInvalidated()?
Yes, exactly.
maybe there is some kind of standard way to find my adapter's item by Id or sth and then make visible the imageview for this item?
Above mentioned way is enough. There is no such standard or special way to do it AFAIK.
Read the Displaying Bitmaps Efficiently introduction and in particular the part about Handle Concurrency. This will give you all the information you need.
i am implemeting sample application in android for creating Dynamic Views.
Please observe below image............
By seeing the above picture i want to create a dynamic view it consists of close imageview, button, spinner and edittext by clicking Plus button. After entering all fields then i click on plus button create new view with above widgets similarly.
I want to delete particular row by clicking delete imageview. and again add by clicking plus, repeat this process untill how many rows we want. Then we click on submit button get all rows of views values and show those details on next screen....
And also tell me other way that is, Is there any possibility of create seperate xml file for that view and use it on our code...
Like see below picture...
Please help me....
Thanks in advance.....
If you Store the Views in a iterable data structure like List, you could iterate over them when a "delete"-Button is klicked and search for the ones to delete by checking the coordinates by calling getX() and getY().
However, like lfor said before, the better way would be to create an own data structure for each row. I would recommend to create a "Row"-class containing the views you want to add per row including the "delete"-Button and passing the Activity you want to add the rows to as a reference. By doing so you can add the components for each row by calling the activity's method addContentView() inside the "Row"-class. Also you know which Views (all of the "Row"-Object you're in) you have to remove, when the delete button is pressed.
I've been trying many things with list items and i'm facing some problems. In my previous question, thanks to #nEx.Software i was able to resolve the problem. But I'm still missing some concepts here.
Right now i'm trying to differentiate between an item's click and a checkbox within it. However, I want to do it without extending the array adapter. Is there a way to use both methods: listView.onItemClickListener() AND listView.getCheckedItemPositions(), together!
There should be a way to use an xml file [doesn't matter how complex it gets] along with extending the available Views and this thing should be done.
Putting it simple, open the gmail app, and u'll find all emails listed with checkboxes where u can click on the checkbox to mark it OR the rest of the item to open the email.
Again, I know that it is doable with extending Adapters and adding an Array for the checkboxes, but, is it possible to use the convenient methods: listView.onItemClickListener() AND listView.getCheckedItemPositions()? is CheckedTextView a part of the solution?
One more thing, rather than just answering me [where i become lazy]
Wheather it is possible or not, is there a verry reliable reference for such issues? I would really like to fully understand everything that goes into this matter... if its not possible, i must be able to tell why!
Thank you :)
add custom row into your listview. into your custom row you add one textview and checkbox into linerlayout and get linerlayout click event.
In my game application am using a listview to select levels. Am activating this listview item onclickable if the previous level is cleared. I need to differentiate the activated and unactivated level's in listview.How can i make it possible? If possible suggest me tutorial. Thank you
you can put your logic for activated and unactivated levels in getView method ,check if activated then inflated activated row otherwisw unactivated row.
First check this and this stackoverflow questions and try some code and post your question if you have any problems. Please try first.
You can use setClickable(false) to disable touch events on list. To make it look disabled, you can change the textView colors in the list items and get such effects.
Thanks
My Question is
I have a expandable list view. in the expandable list i have two buttons in each child in the list. Now i can able to add buttons in the child list. But i dont know how to get parent position and child position. with this parent and child values i need to call another activity. I dont know how to use expandablelistadapter and onChildClick method. Can anybody explain with example. Because am new to android.
You wont get source code implementation as this is not a "gimme-teh-codez" website. Please try to ask questions more specific or tell us whats the problem with your source-code. You can use pastebin.com to direct us to your source code.
I shall point to some links that will help you get started:
Check out : An example showing how to use the child position
and ExpandableListAdapter
Expandable lists have groups which contain children
The solution won't differ from simple ListViews, so you can take a look at something like this article. Basically, when you define your views in getView() (or in case of expandable lists in getChildView()), you define click listeners for the buttons with setOnClickListener(). You use the button's setTag() method to set necessary information like its position and then read it inside the listener with getTag().