I am using custom adapter for listview. In row layout contains, two EditText view & one image view. I want read value of EditText view on button action(which will be clicked at ending). When I manually write entries in edittext box, I am unable to call 'notifyDataSetChanged'. So only old values are set to adapter. Now at end, how to read current data directly from edittext view.
Event editText.getText() also not working. It shows previous data, not modified data.
Thank you in advance.
Finally it is fixed.
My main problem was if EditText view is edited, I need to catch that event. If i use TextWatcher, it signals only when text will be changed.(not when editing is done completely). To catch editing is done, I used dialog. So when user try to edit value from EditTextView, I show dialog with EditText. When 'Ok' will be pressed, it signal that editing is done.
And then update my value.
Related
How can I do this When User Click On the Next Button Activity Should not change only data should change for example if there is TextView then its data should change and so on.
I want output like This Gif
If you have any doubt please feel free to ask in the comments
I think this is able to do with the help of animation.
There are a couple of ways you can do this. You will need to have a list of data which will hold the title and the images. Then you can do one of the following
On your button click, change the text of your TextView and set the image resource of your ImageView by fetching the next item of the list manually each time.
You can use a ViewPager and update the current page when you click on the button
You can use a ViewFlipper and manually add Views based on your data and change views on button click
To achieve this view take on int counter with initial value 0 and use CountDownTimer method.
Create list which contains image and text values in model. on CountDownTimer method every tick you can increase the counter and set image and text again from the list index.
I'm new to Android development.
I need to make a listview with text and icon audio player. The icon has three States, "download", "downloading", "play" and "pause". The idea is that when populating the listview, set the "download" icon if the track is not downloaded and "play" if the track is downloaded". If a person clicks the "download" button the icon should be updated to "downloading" to start the download, then when complete, you should see the icon "play". If the user presses the "play" icon for this element should be updated to "pause".
I can't change the icon . I tried to change them in onItemClickListener and make the onClick in the getView method in adapter, but when scrolling the icons changed to the old. And if you select multiple items in the list, then change all the icons, and I need to change only one, for playing of the track.
I didn't show the code because there is nothing that can be corrected. - all wrong
if you have your own adapter try using a method notifyDataSetChanged();
That is happening due to recycling of views. If you click on an item and you will see multiple items clicked.
Use RecyclerView instead of listView, which will handle recycling by its own and its ViewHolder class takes care of the issue you are having.
And don't forget to notify the recyclerView adapter whenever you make some change in data source (i.e. arraylist)
Check out this example...
Hope it helps
http://hmkcode.com/android-simple-recyclerview-widget-example/
This problem has been bugging me for a while now. I have a list view and in each row there are three EditText in which user can enter data. When a user selects an edit box, the text should be selected, so when he types the first key, the previous text is removed.
This all works perfectly with selectAllOnFocus option set to true. The problem occurs when I have to call notifyDataSetChanged. There is a button in each row that deletes the row and that is when I call the notifyDataSetChanged method of the adapter. After this, when a user selects an EditBox, it doesn't selects the whole text, but the cursor sets to the left side of the text and an arrow is displayed below the cursor.
I tried setting selectAllOnFocus in code and in layout file, but no luck.
What should I try? Am I missing something?
I tried with disabling the focus changed event, no luck.
Thanks!
What is the expected behavior your trying to achieve?
EDIT:
Why not try firing off a two click events manually. Its a slightly hacky solution but if it works than who cares. What you can do is get the view from your list view that you want to have the text selected in and fire off the two clicks in a post like so
myEdit.post(new Runnable(){
public void run()
{
myEdit.performClick();
myEdit.performClick();
}
}
using the post would make sure that the events got fired after the view had been re-inflated after calling invalidate on your listview adapter
Since this was happening whenever I call adapter.notifyDataSetChanged(), I figured I should try to go around it. And this is what I ended up doing:
adapter.clear();
adapter = new AdapterOfWhateverItemsTypeIs(this, items);
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
After this, I got the expected behavior of selectAllOnFocus option of EditText.
I am having a problem with changing a button text. My application has 2 buttons. Button A accesses the internal memory/SDCARD directories on the phone(Filechooser activity). Once a file is selected, the filename of the selected file is stored in a Set list. Each file selected is stored in the set. At the same time, there is a variable counter that increments whenever a file is selected. The other button is the "Selected" button which display a ListView of the selected files. The problem is whenever I attempt to change the text for the Selected button so that it shows how many items was selected, the application crashes.
i.e: if 8 items were selected, the Selected button should be replaced with the text "Selected(8)".
Here is the code:
private void onFileClick(Option o){
selected.add(o.getName());
itemSelected = selected.size();
selectedList.setText("Selected("+itemSelected+")"); // the problem
}
Please if anyone can figure out a way to change that button text I would appreciate that.
Thanks in advance.
all,
We know on Andorid, for a EditText, by default, whenever the EditText is clicked, the soft keyboard pops up to let you enter text. When you click DONE, it closes out and put the text directly to the EditText.
Now, what I am trying to do is, instead of an EditText, I have an ImageView which is to let user enter some comment.(So the ImageView actually is an comment icon). I wish whenever the icon is clicked, it pops up the text editor with user previous entered text, again once the DONE is hit, it closes out and I can save whatever text there back to a string member of the Activity. Is that possible?
So far, all I've seen about InputMethodManager is on EditText control, If it is too complicated, I probably just put an EditText into a sperate Activity.
Thanks.
There are many solutions:
One is to use custom dialog: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Second one is to use a transparent activity on top of that one.
Then you could use FrameLayout and insert another view in an exact position...
I think you should try the frist or second one. Every ImageView can be easily converted into a button by adding onClick event to it.