I am currently trying to get a function working similar to how adding phone numbers work in your android phone contact list. What I mean by this is that if a contact has more than one phone number you can click the + button and it adds another field to the display for another number.
What I'm trying to do is when the user clicks a + button it adds a new spinner right below the existing spinner with the same data in it. I'm not quite sure how to go about creating the spinner to appear below the existing spinner but still above all the content below the existing spinner. Any suggestions?
Related
So I've been developping an app on Android Studio and at some point I need to display couples of values composed of texts and images but I have some issues with the display.
Let's say here that I want a list of fruit names associated with a picture, I'd like to display it that way :
Example
Each image and its related text is in linearlayout, so it's a list of linearlayouts.
The "add fruit" button open an alerdialog where the text and the image can be chosen, by clicking the 'ok' button in the alertdialog the name and the image are saved in a sqlLite database (which I already have programmed), and the linearlayout has to be added in the current list as the dialog is dismissed.
So the issue here is that:
I don't really know how to dynamically display each one of these linearlayouts in this specific order.
I don't know how to make it so that when a new fruit is added and the dialog dismissed, the list in the activity is refreshed directly.
I've been thinking of using a listview but listviews are only horizontal OR vertical but in this case I kind of need a mix of both.
Another idea was to delete the layout containing all the linearlayouts (all the list) when a new fruit was added, and then take my database to create all the linearlayouts again. But dynamically I don't think it will work, the refresh won't be done (?)
My last idea was to create a fragment and use my database in the onCreateView method to display every elements. And to refresh it, I'll just detach and attach again the fragment to the activity each time I add a new element.
I don't think my ideas are the optimal or even a correct way to do it, I've been struggling with it for a while. If you have any suggestions or ideas to help me, it would be great :)
when user select text on android..some buttons will appear,like "copy & paste".
what i'm trying to do is to make my app show a button on the screen when text gets selected on my android phone.
These answers are what you are looking for:
How to add item into popup copy/paste menu on a android selected TextView?
Making custom copy and paste menu appear when text is selected
I am working on a app which add its icon in android default contacts app just like whatsApp icon appears in contact info. I want to update my apps icon dynamically on receiving some events, say a user comes online, then icon in contact list should be different then the icon shown when user is offline.
Can anyone suggest any way to do this?
Thanks
I assume your contact list is a ListView, and that you have an adapter that inflates each cells layout (that is, displays the icon and name of the contact).
Whenever you detect a change has occurred (an event was received) (maybe consider using a Loader if you aren't already), you should be able to call Adapter.notifyDataSetChanged() to update the cells.
I have created a new application with Scrollable Tabs + Swipe, I start with the auto-generated code.
The activity extends FragmentActivity so I'm obviously using Fragment in my project
The user taps an item in the menu which takes the user to another tab, like so
mViewPager.setCurrentItem(SectionsPagerAdapter.FRAGMENT_INDEX, true);
This tab isn't visible until the user selects the menu item
A new Fragment is instantiated, with the appropriate layout file, which, currently, just contains an AutoCompleteTextView and a RelativeLayout. This is how I set up the ArrayAdapter:
arrayAdapter = new ArrayAdapter<String>(context, R.layout.fragment_layout, R.id.auto_complete_text_view, arrayData);
and then set the adapter on the AutoCompleteTextView.
Everything works fine, I get the suggestions in the drop down, but the problem I am currently facing is that when I tap the drop down item, nothing happens. The AutoCompleteTextView doesn't get populated with the selected drop down item.
I noticed that the when I select the drop down item I get the "blinking line".
I have tried creating my own AutoCompleteTextView and using different contexts, but I am getting the same results
Any help is much appreciated.
Ahaha, OK, so my mistake was when I was setting up the ArrayAdapter I was using the layout ID of my fragment, but I changed it to android.R.layout.simple_dropdown_item_1line and is now working perfectly fine =]]
In my application I am having 5 checkboxes for displaying different task on another activity
in this user have to select 1, 2 or 3 checkbox which he/she want to see on next screen.
In first screen i am having Save button. after checking checkboxes user have to click on save button.
My question is I want to show only those Expandable list on second activity which is selected by user on check box when user click on save button
please tell me how to do this?
Thank you very much.
save the selected check-boxs and then when you inflate the expandable listview adapter return views only for the selected ones
create dynamic array of selected Item, and assign this array to the group array