FAQ Database Discussion Community


How to pass data between multiple Fragments in Android

android,android-tabhost,android-listfragment,android-dialogfragment,dialogfragment
In my main Activity, I have a DialogFragment that contains a FragmentTabHost. I have two tabs, one that is a DialogFragment and one that is a ListFragment. When either the 'OK' button is pressed in the inner DialogFragment or when an element in the ListFragment is pressed, I want to...

How to pass selected item from ListFragment to previous Fragment after calling popBackStack()?

android,android-fragments,android-listfragment
I have prepared a very simple test case with 1 activity and 2 fragments for my question: MainActivity.java (stores selected item in shared preferences) MyMainFragment.java (displays a text view and a "select" button) MyListFragment.java (displays a list of items) Initially MainActivity displays MyMainFragment. When user touches "Select item..." button, MainActivity...

when doing query for parseUsers and shoing them in listFragment, while switching fast from fragment to fragment the app crashs

android,parse.com,android-listfragment
Sorry for asking near same questions, cause my low reputation can't comment there. So I am using parse.com and doing a query for users and putting them in a list that in fragment. The app works, but when I switching between fragments fast, it crashes with exception: java.lang.IllegalStateException: Content view...

ListFragment inside a ScrollView Android

android,android-layout,android-listview,android-listfragment,android-scrollview
Here is my current layout: <RelativeLayout> <ListFragment/> </RelativeLayout> I want to add a picture just before the fragment, something like this: <ScrollView> <RelativeLayout> <ImageView/> <ListFragment/> </RelativeLayout> </ScrollView> But, ListFragment use a ListView, and I want the picture to moves with the ListView. It must work if we replace the ListView...

Correct way and location to initialise adapter

java,android,android-activity,android-adapter,android-listfragment
I'm trying to setup a filter for my list view but I've come across these errors. Cannot resolve symbol 'myAdapter' I know that myAdapter hasn't been initialised, but I don't know which of my classes I need to declare it in. error: method setOnQueryTextListener in class SearchView cannot be applied...

How to maintain ListView fragment state after orientation/configuration change?

android,android-fragments,android-listview,android-listfragment
I have a ListView fragment in my application that is experiencing some issues. When I scroll to a specific element in the list view, then rotate the device, the list view resets to the top of the list. When I enter multi-select mode in the list view, then rotate the...

Android: Displaying a list in a fragment

android,android-listview,android-listfragment
I have a existing fragment, in which i want to display typical address kind of information like Street, City, PIN and List of Phone Numbers. To display List of Phone Numbers, i added listview in addressfragment.xml: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp" >...

Replace list in master activity with another list and remove old list from view

java,android,android-fragments,android-listview,android-listfragment
When staring my app a list (list_main) is displayed in the master fragment. There is also a 2nd list fragment that is supposed to open when I clicking the 1st list item from my main list fragment, however after clicking the 1st list item, the main list fragment DOES disappear...

NotifyDataSetChanged from fragment container

android,android-fragments,android-listfragment
I have an app with an Activity that hosts a ListFragment, an EditText, and a Button. When the user presses the Button, I want to add the text in the EditText to the ListFragment. I know to do this, I would have to call the Fragment's adapter's notifyDataSetChanged() method, but...

How can I point to EditText elements that are generated dynamically in a ListView in Android?

android,listview,android-listview,android-edittext,android-listfragment
I am creating a ListView in a ListFragment and it is being populated dynamically, and I have no clue how many items are going to be there. Now I need the user to set the text of EditTexts for each item in the ListView in order to save this text...

ListFragment: Runtime error "Your content must have a ListView whose id attribute is 'android.R.list'

java,android,listview,android-listview,android-listfragment
I have a listfragment class: public class activityfeedScreen extends ListFragment implements OnItemClickListener { private ListView activityfeed_feedList_listView; private ActivityFeedBaseAdapter adapter; public static final activityfeedScreen newInstance() { activityfeedScreen fragment = new activityfeedScreen(); Bundle bdl = new Bundle(1); fragment.setArguments(bdl); return fragment; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View...

Android layout design: composite Relative vs fragments

android,android-layout,listview,android-fragments,android-listfragment
I want a simple scrollable ListView. I have a custom adapter that makes each row display a picture and some text. Underneath I want a few buttons. I'm looking for a layout like this sample picture: This seems like it should be trivial. I have a single main activity that...

ListFragment is not updated with notifydatasetChanged

android,android-listview,android-listfragment,notifydatasetchanged
I am stuck with listfragment as the fragment listview is not updated with new item addition in allData arrayalist. The data come from server which is passed to listfragment class with the help of interface and result arrives in passData(ArrayList> allData). I had checked the size, it is alright in...

Creating listview in fragment android

android-layout,android-fragments,android-listfragment,layout-inflater,fragmenttransaction
First of all, Thank you for answering. I am a newbie in android app development .I have made a fragment called fragment_list for creating a listview dynamically.The problem is that when the application runs the screen remains blank.I have tried to make a listview that has an image and a...

Problems with my ListFragment and DatePickerDialog

android,android-fragments,android-studio,android-listfragment,android-datepicker
I'm new to Android development and have a problem in my ListFragment. I'm trying to start a DatePickerDialog with a button. The code in my ListFragment follows: @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); b = (Button) getView().findViewById(R.id.button_set_date); et = (EditText) getView().findViewById(R.id.editText_choose_date); b.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v)...

ListFragment with a custom view hierarchy results with zero width / height children in onViewCreated

android-layout,android-fragments,android-listview,android-listfragment,android-inflate
I'm inflating View for ListFragment with: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_home, container, false); } In public void onViewCreated(View view, Bundle savedInstanceState) I'm checking the view children's width/height and it seems that they are always 0. Why? This is my fragment_home.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"...

List fragment not appearing owing to No view found for ID error

java,android,xml,android-fragments,android-listfragment
I'm trying to launch a list fragment but it only seems to be working on tablets. When I run my app on phones the app crashes. Does anyone know how to resolve this issue? Code are below. Error Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f0c0050 (com.apptacularapps.exitsexpertlondonlite:id/master_container) for fragment...

Names appearing twice in list view items

java,android,arrays,android-listfragment
I'm trying to set up a 2-line list view but each string seems to copy itself within the item rather than showing it once. How can I prevent this from happening? i.e. I need the data to appear like this: for Item 1 - America, America Description rather than America,...

Unable to use string resources for list view items

java,android,android-fragments,android-listview,android-listfragment
I'm trying to use string resources for my 2-line list view items rather than hard-coding them but I get this error. How can I fix that? Before using string resources public class ListData { public static final String[][] items = { {"America","America Description"}, {"Europe","Europe Description"}, }; } After using string...

Why is my ListView item selected, but not highlighted after click?

android,listview,android-listfragment
I'm working with the Master-Detail Flow and using a Custom ListView, which is defined by a BaseAdapter. After user touches the List item it doesn't remain selected. I thought I could solve it by defining a selector, <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Selected Item --> <item android:state_selected="true" android:drawable="@android:color/background_dark" />...

ListView not updating after web service Sync

android,android-listview,android-listfragment,android-syncadapter,android-webservice
I have impelmented SyncAdapter that calls webservice and insert/update database. I would like to show some of this data in ListView so i implemented ListFragment in witch the data is displayed via CursorAdapter. And everything works ok, except when I get new data from web and insert it into database,...

Update listFragment when camera changes in MapFragment

android,android-viewpager,android-listfragment,mapfragment
I have an app with two fragments and I want to implement the ViewPager and ActionBarTabs to it. My question is: Is there any way to recreate my ListFragment each time when user moves camera in my MapFragment ? Each move assigns different values to an array which I use...

Passing data from DialogFragment to ArrayAdapter in ListFragment

android,android-listfragment,android-dialogfragment
I have ListFragment in which each row has button which after clicking opens dialogFragment in which user can choose 1 of 10 options (it is a listView of 10 options). I want to save this choice in SQLite database (it's already done) and reflect choice in the particular list row...

Android ListFragment with custom CursorAdapter not showing data

android,android-listview,android-listfragment,android-cursoradapter
So basically I have a ListFragment setup like this public class ObavijestiFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { private View mApiError; private ObavijestiAdapter mAdapter; private static String TAG="ObavijestiFragment"; public static ObavijestiFragment newInstance() { return new ObavijestiFragment(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_obavijesti,...

ListFragment.onListItemClick() not being called; possibly due to Navigation Drawer

android,android-layout,android-listview,navigation-drawer,android-listfragment
I am perplexed as to why my onListItemClick() method is not being called. I was reading this question on the subject, and it mentions that any other components in the layout need to be set android:focusable="false" However, here is my layout for that class. As you can see, it has...

List view not returning to original state after clearing search

java,android,xml,android-activity,android-listfragment
I'm trying to get my list to show all my items again whenever I cancel a search from my search view but for some strange reason, the list gets stuck with the results only from the previous search. Does anyone know what is wrong with my code and how to...

ListAdapter refuses application after changing array type to int

java,android,arrays,android-listview,android-listfragment
After changing the array type of my list items to 'int' my list adapter refuses application of it. How can I fix this? ListData.java public class ListData { public static final String[][] items = { {R.string.america,R.string.america_description}, {R.string.europe, R.string.europe_description}, }; } within FilterListFragment.java: private void initialize(View view) { //Set up list...

How to dynamically change text of empty view in listfragment

android,android-listfragment,empty-list
I have red many solutions regarding this but none of them solved my problem. What i want to do is, when my list view is empty its ok if the default empty text view shows up (which is declared in xml) but what if i want to change its text...

Android Loader used with SimpleCursorAdapter and ContentProvider not updating

java,android,android-contentprovider,android-listfragment,loader
I have a list fragment which loads data from a ContentProvider using a Loader and SimpleCursorAdapter. I think that I have followed correctly the directions given by google examples, but my ListView is not updated when underlying data changes. This is what I'm doing: ContentProvider @Override public synchronized Cursor query(Uri...

ListFragment appearing twice on phone

java,android,xml,android-listview,android-listfragment
I'm seeing an undesired appearance of my list fragment when I run my app on the phone emulator. On the tablet emulator it appears once but on the phone emulator it appears twice. How can I fix this error for the list to appear on the phone emulator only once?...