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 =]]
Related
in the beginning i want to apologize for my bad english but im currently working on an application, i have 2 firebase tables (propertys and tennants) sorted by the logged user (doesn't even matter for my problem). So i have 2 possibilities in the navigation drawer, i can add and view propertys, view is enabled in the recyclerview, adding is done by fab button, both RV and fab are in an fragment, same goes with tennants. I can click on each of items and view all the details about them in an activity, so what i want is when i click on an property item and it opens activity where my property details are, i have a button that should add tennats to that specific property and list them in that activity (property details). You guys got any solution? I tried onClick of that button to open tennants recyclerview and select multiple items and then onBackPressed to try to save them but i simply cannot get it working, then i tried with alertCustomDialog where it should list all the tennants (part that iam not able to do) and with checkboxes select tenants that i want to, please if anyone can help or has some clue how to do this, please HELP! :=)
I want to show 2 items by default and add items in recycler view when we click button in main activity. Those item contains edittext so I have to get the data from edittext in my main activity.
Basically you have to create two different ViewType/Layouts to implement this.
Sharing related links below..
https://www.geeksforgeeks.org/how-to-create-recyclerview-with-multiple-viewtype-in-android/
How to create RecyclerView with multiple view types
For adding items to Recycler view when you click in a button you should add the item in the list and notify adapter that new item added at the end of the recyclerview using notifyItemInserted()
and for the other question for getting the edittext value from the adapter to the activity you can create a callback interface that implemented in the activity and pass the reference to the adapter and fire it from adapter when Edittext value is changed
I'm trying to create app(workout plan) which use a lot of listView.
It means: When I click "Create Exercise" -> new name of exercise is created in listView. One ListView for every names of exercises. ( I have this ).
But when I click on every item of this listView I want to create new series for each item. But when I click "Create new series" in first item and when I click the same but in a second item it's created in one listView.
But I would like to save this to another listView for every item.
Is it possible? As I think at now, every item should have own listView.
Actually, my question is: Why are every series created in one ListView?
Because the is one common activity for create series?
Could someone help me to find a solution for my case?
In this photo I show my idea.
No need to create a new list view for each and every item.I recommend you to create a table in your db and retrieve items on your need and populate the list view on item click of your list view.
You can use below links as a references to create Custom List view as you have mentioned in your question:
http://www.pcsalt.com/android/listview-using-baseadapter-android/
http://theopentutorials.com/tutorials/android/listview/android-custom-listview-with-image-and-text-using-baseadapter/
first, you have to create an activity in that activity create one custom listview and in your custom adapter- register click listener like "convertView.setOnClickListener(...){...} in getView(...) method.
In that click listener you have to open another activity and put some value you needed in putExtra(..) like startActivity(new Intent(getApplicatonContext(),AnotherActivity.class).putExtra("tag","value"));
And in second activity you have to get that value using getIntent().getStringExtra("tag");
After that create another custom listview based on that value..
Hope this help you
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/
When the user first loads the listview, it pulls the date column from an sqlitedb and populates the list. When they click on a date, I put that date in a variable. I then want to display a list of items from an array. And then when they click one of those items, it again pulls data from an sqlitedb and populates.
So initial listview:
12-2010
01-2011
03-2011
04-2011
click on any date, set mDate = clicked item
change listview to display what's in an array, then it's looking look
Option 1
Option 2
Option 3
Option 4
click on an option, set mOption = clicked item
change listview to pull data based on mOption from the db.
I know how to get the listview to pull info from each of these sources, what I'm not clear on, is the best way to handle these adapter switches. Any suggestions?
There are two options. You can have multiple ListView that each have their own adapter that you switch between or you can have multiple adapters that you just set to the ListView. Personally I would go with option 1 so you can put the ListViews in a ViewSwitcher and animate the transitions.
If data may change at any moment, the cheapest and most reusable way I believe would be to use:
public void updateContents (ListView lv, List<String> list) {
ArrayAdapter<String> myAdapter = lv.getAdapter();
myAdapter.clear();
myAdapter.AddAll (list);
lv.setAdapter(myAdapter);
}
But, this only works in android 4.0 or later. 2.3 and lower does NOT support ArrayAdapter.AddAll(object);