Reading text file to ListView in Android? - android

I would like to know how to read the contents of a text file line by line and add it to a ListView in Android.
Look at my scenario:
I have three activities-add_new, show and show_all. In the "add_new" activity, there are two EditText fields and a button. When I enter text in both the EditText fields and press the button, it should be stored as two separate lines in a text file in the Android filesystem.
The "show_all" activity contains a ListView, which populates the contents of the text file in such a way that, the one line is shown as the title (the content read from the first EditText field) of each item, and the immediate next line (the data read from the second EditText field) is the data associated with it in the listview.
When I click any item in the ListView, a new activity, "show" displays the details ofthat particular item. When I press delete button in that activity, the original text file need to be updated in such a way that, the lines associated with that item need to be deleted.
How do we do this?

Related

Custom Listview with Text and two Images

I am new to Android Development and I am making an application in which I have an EditText and below EditText there is submit Button.
I want that when I write something in EditText and then click submit, the Edittext value will show in Listview with pre defined two Images i.e. their is EditText value in listview and on the right of it two Images also added with that Submit button. These images are Delete and Edit Images so that whenever i click on delete it delete that item and whenever i click on Edit image the EditText value will be ready for editing.
I know that this will be done by getView method and a holder but i could not find any best example for that.
Can anyone provide me the best example for holder and custom listview regarding my application?

i have a list view that contain two views textview and edittext. how i can get entire edittext data after pressing a single button

i have one textview and one edittext in a single row inside a list view ..
now i want to get values entered inside the edittext one by one and store it in an array (array of objects. each object contain two variables that will hold these two views data of single rows)
. i have a button at the bottom of this layout that contain the listview . my question is how i can do it when i press that button and after pressing my entire edittext values will get one by one and will store in the array.

Single-choice list with input-field

When the user hits a button in my app, it shows a persistent single-choice-list with use of AlertDialog.Builder and the setSingleChoiceItems()-method. The list is populated with values from a simple array, which is not known at compile-time. When the user hits "OK" in the dialog, the value is saved.
Now, I would like an option in this list where the value is a textbox and not populated from the array. Is this anyhow possible, and which way should I go?
I've tried to sketch it here:
[] option a
[] option b
[] option c
[] "TEXTBOX HERE"
Well it can get complicated but, here it is..
You can add onClickListener to that radiobutton and set its text like "Enter the text".
Then, in in onclick() open a custom dialog box which accepts text. then set value received from there in your radio button text by radioButt.setText(value entered);.
Custom Dialog example. in here just add editText in place of image view and text view.

Advanced AutoCompleteTextView. Many-to-one map

I want the autocomplete view to display multiple items for the same text item.
ie. with an input data, {{a,b,c,d}, {e,f,g,h}} the user could search and start typing in b, but only 1 item from a,b,c,d would be displayed in the autocomplete section.
How would I go about this?
Thanks
I found I could solve this problem by adding all the elements to the autocompletetextview like normal
However, for the items that had "aliases" I put them in as 1 item, separated by a separator character and a space. The space allowed the item to be selected using the normal functionality. Then I used a custom view for each of the items which identified which 'part' of the string was being entered and displayed that part in the dropdown item.
For my solution, I then hide the autocompletetextview, but you could also just call setText to overwrite the default behavior.

modify particular list item

i want to edit the particular list item after the,all data loaded into listview using base adapter.
we can achieve this by reloading the listview with edited value,but i want to do this without reloading the entire listview data.bcoz the data is huge
If I understand ur question properly, When the list item is clicked, u need to make it editable.
Keep two views, one for editing ( EditText ) another TextView for showing.
On Click of list item or TextViw, make TextView Gone and make EditText visible.
When the editing done ( may be other list item click or Done button of keyboard ) copy the content of EditText to TextView and make EditText Gone and TextView visible.
I have done the same for some of the requirement I had in my pet project

Categories

Resources