Get value from Edittext in Recycleview - android

I need get value from each edittext in RecycleView Adapter and add it in ArrayList for send it in MainActivity

Related

Android pass value to Spinner

I have to pass a value in the sqlite db spinner of another activity.
the value of the step as follows:
extras.putString ("category", tv4.getText().toString ());
But then as I insert it in the spinner?
spinner.set ...... (i.getStringExtra("category"));
Presumably your spinner has an adapter and an array that fills that adapter. You need to first find the index of the string you are passing in from the array. Then you will set the spinner's position to that index.

Listview Row incrementing with new value

I have a listview with radio buttons now i need to add one value from a edittext after typing some thing in the edittext the typed text should appear in the listview as next row.? how it is posible.?
ListView with simpleArrayAdapter :
Follow these steps it may help:
1. Fetch the value from edit text after the user types using gettext()
2. Insert this value in an array.
3. create a list view.
4. create an arrayAdapter with the already created array as source.
5. Now set the adapter with listview using (array variable).setAdapter(adapter name);
For every time the user updates use notifyDataSetChanged() to refresh your listview with the new contents.
Pseudo code:
onClick(){
array.add(editText.gettext());
adapter.notifyDataSetChanged();
}
Click here for more.

populating spinner using ArrayAdapter

I have a list of custom objects, that I created from downloaded JSON array and I would like to populate the Spinner with just one field from my list, but I still want to keep the whole onItemSelected.
Currently I am doing it like that
ArrayAdapter<Country> myAdapter = new ArrayAdapter<Country>(Prototype_activity.this, android.R.layout.simple_spinner_item, ValueHolder.countryList)
spinner.setAdapter(myAdapter);
spinner.setVisibility(View.VISIBLE);
So how do I say to adapter to use only one field from each item?
...and I would like to populate the Spinner with just one field from my
list, but I still want to keep the whole onItemSelected.
If you are going to use an ArrayAdapter then implement the toString() method for the Country class to return a String representation of the desired field.

Android - Get data from a dynamic EditTexts by ID

I have the code below in my adapter that creates dynamically EditTexts and set IDs using the method "et_settingValue.setId(setting.getId());".
An Editbox is created in every instace of the class Setting and it also contains a variable to store its id.
This part is already working properly, but now I need to access all those created EditTexts by ID and get its data. If possible, I would like to avoid creating another array to store the EditTexts because I already have their IDs.
Is there any way to do it using the dynamic IDs I already have?
EditText et_settingValue = (EditText) view.findViewById(R.id.et_settingValue);
et_settingValue.setText(setting.getValue().trim());
et_settingValue.setId(setting.getId());
Update 1
In my activity, I am trying to do this:
EditText et = new EditText(listView.getContext());
//loop to get each object child
settingConfig.getConfigName(); //ok
settingConfig.getConfigValue(); //ok
settingConfig.getConfigId(); //ok
et = (EditText) listView.findViewById(settingConfig.getConfigId()); //not working
et.getText(); // off course it will not working
Many thanks
ListView use a RecycleBin to reuse the view created from Adapter, so ListView will only contain a few child view, and you cannot find all EditText in the ListView.
To solve your problem, you should use a Map to record the value of all EditText. Add TextWatcher to each of them, and refresh the value in the Map on text changed.

Getting spinner value without using events

I'm trying to get the value from a spinner (android) without using events, like getting the value from a textbox.
Thanx.
Easy just call up selected item on the Spinner
String Text = mySpinner.getSelectedItem().toString();
You have getSelectedXXX methods from the AdapterView class from which the Spinner derives:
getSelectedItem()
getSelectedItemPosition()
getSelectedItemId()

Categories

Resources