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.
Related
I'm using Recyclerview to show a list. I want to delete some items like IOS. In my listview template I have added a button to delete item which is invisible by default. In my activity I have another button attached at bottom (Not part of listview) and on tap of this button I want to make all delete buttons of listview visible.
My Question is how can I get reference to all delete buttons of listview in activity and is it the right way to do this?
Thanks
Assuming you have ViewHolders set up, you already have references to all the buttons in your list. All you have to do is to make them visible for every item in the list with a simple loop.
In case you haven't implemented ViewHolders I suggest you check out the documentation and take a look at some simple tutorials on how to use them.
On a side note. If I understood correctly you're making a bottom tab for your app and since you referenced iOS I gotta say this; Remember that Android and iOS are two unique operating systems with their own ways of handling things. Check out Googles pure Android documentation.
In your question title you say RecyclerView, but in your text you say ListView. The solution is similar either way, but it's best to be perfectly clear what you're doing.
In either case, there are at least two different solutions.
First, you could use a boolean flag to determine if all the the item buttons should be showing or not. You check this flag at the time the item view is inflated or created and toggle the button accordingly. If the boolean flag is ever changed, the easiest thing to do is tell the RecyclerView/ListView that the underlying data has changed and to redraw all the views. Call notifyDatasetChanged on the adapter.
The other thing you can do at the time the item buttons should change is iterate all the visible item views, find the button, and change its visibility. With RecyclerView, you can do this, and with ListView you can do this.
good evening , I need help about filling a list view from a MySQL Database,
i don't know how to do it becaus i'm beginner in android
i wanna icon and 3 text views the first is title bold and the second is the RIB and the last one is in the bottom and right of the list view
Your question is a bit too generic and not clearly defined. That's probably why it got down voted. I'd say your best bet is to start with the documentation. Start by reading about ListView and possibly Adapter and try it yourself. If you still have problems, ask a specific question about something you don't understand or can't get working. The best specific answer I can give is that you will need to define a custom adapter to create the item view you want. You will most likely want a layout xml for that item view.
I have a complex ListView involved layout in my Android project that looks something like the picture attached. The layout has a top, fixed part (the meeting details) with TextViews Join, Edit and Delete that are clickable (really listen to onTouch events), with Edit and Delete only showing up for the meeting owner/creator.
There is, however, the ListView part below the fixed part as well, and this part has a number of unknown comments, presumably posted by people who have been invited to the meeting. Anyone whose account has access to this meeting, and who sees this layout can comment on this meeting information layout. However, only comments created by a person have the links Edit or Delete (again, onTouch listeners on those TextViews). In this way, think of this page as the detail page when you click on post in Facebook and you see all the comments posted, but are only able to edit/delete your own comments.
I thought I could set out with a solution like this page, with the top, fixed part and the ListView in the same fragment layout, but that will only work if I have the same links for all the comments. That is not the case for me, because the links Edit and Delete for each comment will only show up if the comment is by the comment author.
How should I do this? Do I have to write my own Adapter? Is that the only way? How would I go about writing my own Adapter? Any pointers/tutorials/links appreciated.
Lastly, I was wondering how I can set listeners for each clickable item on the comments. I know I have to use setTag() and getTag(), but don't know where to do this.
Any help is deeply appreciated.
Vogella.com has some good android tutorials. Here is one for writing a custom adapter. The android docs also have a tutorial on listviews, but it doesn't look like they tell you how to do custom adapters. They do, however, tell you how to handle clicks on the list view.
You can setup your comment view to display the Edit and Delete buttons or not in the getView() method of your BaseAdapter class.
I ran into the situation that I need a way to edit the data of list-view item from another activity. I can handle the click event on each item, then edit it on the fly. However, I still prefer to handle all the editing in a separate activity. My listview item is customized from BaseAdapter.
Here is my main page,
Each item within the ListView, contains two other TextView. When the I hit the menu setting, it will go to another activity where I can edit and update the information:
I'm currently having two solutions in mind. Either retrieving data from the previous activity and update the whole ListView (which I think it's kinda expensive in the case user just edit one item). Or I can just get rid of the ListView and create a bunch TextView in the xml, by doing this I can just reference to each TextView by their id. So my question is, which way is preferred in this case? Any suggestion would be greatly appreciated.
Your ListView is displaying Email, Name, Headline, etc? That should be a fixed XML layout with TextView entries, I think. ListView is for variable numbers of elements. You CAN implement it with a ListView, but I wouldn't.
However, your concern about updating the whole list being overkill, I wouldn't worry about that either. You're talking about 7-10 fields. The amount of time Android needs to run through its lifecycle and display everything will dwarf you updating a few fields.
You can use SharedPreferences for this. You can create a wrapper class through which you can access the preferences.Thats the usual way to go about solving these kind of problems. You can check this for details.
You can have it as a variable in your application class, so that you can access that in a global context.
Use text views instead. List View code has been optimized for large amounts of data only and not recommended for small data.
In my app, I should set up a "real" custom listview.
For example :
First line(Some Text) Checkbox
Second line(Some Text) Spinner
What I mean is that each line has different widget. In the example, for the first line, we have a checkbox, for the second, it is a Spinner.
Does someone have any idea of how I can set it up?
Thanks a lot!
Do you really think you need a ListView? Or could a ScrollView fix your problem already?
If you definitely need a ListView, read my answer here: How to add multiple headers throughout a single ListView with addHeaderView()?
You can define different types for your items and return a different layout for each type, while still having the possibility to get higher performance by using convertView.
Check out an example given on this page for defining custom-listview: http://www.androidpeople.com/android-custom-listview-tutorial-example/
Same way, you can define your custom-layout for listview, you just need to implement getView method.