I am working on a recylerview which contains several edit text and 2 textview beside each edit text. Initially I want empty edit text when activity is loaded, after that putting some values in 1 or more edit text randomly. I do not want to loose the value on scroll up or down. Please provide a solution for that if possible.
Related
I am trying to create an Android app where data is read and alignment differs if a certain string is contained in the data. The data is then appended onto a textview with a carriage return. Using append, is there any way for me to change the text alignment for individual line entries? Currently what I've been doing is this
if(returnedData.contains(myVar)) {
myTextView.setGravity(Gravity.END);
} else {
myTextView.setGravity(Gravity.START);
}
Obviously this does not work because it changes the alignment of every line with each new append. Thank you ahead of time for any help.
android:layout_gravity is used to align the text view with respect to the parent layout. android:gravity is used to align the text inside the text view.
put these lines in your xml
Further make sure that you are trying to align the text inside the textview to the right or do you want to move the text view itself to the right with respect to the parent layout, solution will differ with different scenario.
also you can take two different textview and align that textview rather than setting them on single textview.
I have a recylerview with edit text on its row which is populated with values coming from the server.
Now the user will be able to add some edit text and some not. My problem is that if user entered some values in edit text then I am able to get these values and other not. Lets say recylerview has 5 edit text and user entered values in 2 edit text then I have to receive these 5 edit text values into containing activity of adapter.is that possible or edit text is recommended on rv?
You can add a text change listener to the edit texts
refer: android on Text Change Listener
I have came across these type of questions a lot, But none of the answers solved my problem.
I am developing a mobile shopping application model. I have a custom ListView with an ImageView, and EditText(quantity), 2 Buttons for increasing and decreasing the quantity, 3 TextViews one for item Name and other two for prices and I am dynamically loading a number of Buttons for NetWeights based on the requirement through Java code and I am implementing it using CustomAdapter(Class) extending BaseAdapter and getView().
Problem 1:
When I use the condition if(convertView==null), setTag(holder) and getTag(), the dynamically loaded Buttons are getting duplicated and gets doubled in number.
Problem 2:
While scrolling the custom ListView I am loosing my data on 2 of the TextViews while the other TextView(name) is fine because in that TextView I don't Change data on runtime. On the other two TextViews(prices) I change the data on runtime using ButtonClicks(increase and decrease) where at that time when I scroll the two TextViews, it looses its content. Actually I had this same problem with the EditText(displaying quantity), I solved it using the TextWatcher by getting the value and passing it in an array and again setting it. I used the same technique (i.e) the TextWatcher for the TextViews But that did'nt Help. I also tried removing the TextWatcher and setting the text with the array and adding TextWatcher. Still I am loosing my content in those TextViews
Any Suggestions??????
Problem 1:
While using ViewHolder (setTag(), getTag()) we will be reusing the views.
For example: Let's say we have 10 listview items and the screen can display 3 items at a time. Lets say we add 2 buttons to list item 1. First time when we load the listview we will see two buttons. Lets say now we scroll down and come back to the list item 1 again, as we are reusing the views, we already have 2 buttons and if we have the code to add buttons using getTag() then 2 more buttons will be added. I think this may be causing the issue of button duplication. To add little more information, list item 1, list item 4, list item 7 and list item 10 will all use same view, as our screen in this example can display just 3 items.
Problem 2:
One idea is to store all these text values in the arrayList.
For example, lets assume we have one textView inside each list item that can be incremented/ decremented. Set textWatcher on this textView and whenever text changes add it to the arrrayList using 'position' as the index. Inside getView method when you do getTag() try to set the textView using previously stored text (that was stored inside the arrayList)if exists.
I'm trying to build an android activity screen which displays a table with the last column as editable checkbox. Can someone help get started on this?
Also I was wondering if there was a tool like ArrayAdapter, Listadapter which displays your data from an array, except what I want in this is with the checkboxes for each row. Thanks
I have faced one such problem for which I created a customized listview which looks like a table, and every row you can dynamically fill the data using custom listview adapter.
for editable checkbox, on click of the row you can open an edittext in dialog and after that you replace it with the checkbox text.
I use a ListView for text-items in my APP. But I have one problem: if a put a text with numbers, the numbers are convert to a link to show the phone dial screen. Can I disable this?
If you are defining you list items as TextViews in a layout file then use android:autoLink="none" to prevent emails/urls/phone numbers etc from being shown as clickable links.
You should also be able to use setAutoLinkMask (0) on each individual TextView list item if you are creating/adding them manually.
I haven't tried it myself but I think that's how it works.
It looks like this:
I have a standard ListView with a Image and a TextView (thats one item).