fragment

Android - NullPointerException on SearchView in Fragment

一个人想着一个人 提交于 2019-12-13 04:59:36
问题 I am always getting searchView null at below line in my fragment class: SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); here is my fragment class, Please find onCreateOptionsMenu method at bottom: public class FriendsListActivity extends Fragment implements EventListener { ArrayList<Users> friendList = new ArrayList<Users>(); ArrayList<Users> blockedList = new ArrayList<Users>(); ArrayList<Users> famliyList = new ArrayList<Users>(); ArrayList<Users>

Why is my options menu not showing the settings menu item correctly?

这一生的挚爱 提交于 2019-12-13 04:56:27
问题 I This is from https://developers.facebook.com/docs/android/scrumptious/authenticate This is my code (identical from the tutorial) for the options menu part @Override public boolean onPrepareOptionsMenu(Menu menu) { // only add the menu when the selection fragment is showing if (fragments[SELECTION].isVisible()) { if (menu.size() == 0) { settings = menu.add(R.string.settings); } return true; } else { menu.clear(); settings = null; } return false; } @Override public boolean

Google Plus API Share URL functionality removes hash fragments from URLs

时光怂恿深爱的人放手 提交于 2019-12-13 04:40:32
问题 I am trying to share the following URL via the Google Plus API http://www.w3.org/TR/WD-html40-970708/htmlweb.html#h-4.1.1 I am using the following URL to share that: https://plus.google.com/share?url=http://www.w3.org/TR/WD-html40-970708/htmlweb.html#h-4.1.1 However, the fragment is being removed, so I am only able to share the following http://www.w3.org/TR/WD-html40-970708/htmlweb.html The documentation doesn't mention anything regarding constraints about hash fragments. Has anyone already

Fragment causing NPE upon starting service with onCheckedChanged

浪尽此生 提交于 2019-12-13 04:39:30
问题 I have an activity which displays fragments dynamically. The default fragment has a switch that, if enabled, starts a service. What's happening however, is that whenever I toggle the switch I get a nullpointerexception. The errorlog is here What can I do to fix this? Should I perhaps throw the code for the button over onto the main activity instead of the fragment? This wouldn't be a problem, but I'd really like to have it in the fragment. My Fragment: public class DefaultScreen extends

Refresh Fragment Him Self

孤街浪徒 提交于 2019-12-13 04:14:20
问题 It's possible refresh an fragment him self? Like an activity context.finish(); context.startActivity(context.getIntent()); 回答1: I haven't tested, but maybe something like getActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.the_fragment_container, new MyFragment()) .commit(); 来源: https://stackoverflow.com/questions/18517938/refresh-fragment-him-self

Save Fragment objects

Deadly 提交于 2019-12-13 04:09:33
问题 I have an Activity that Displays Fragments one at a time , now each fragment load it data from server and keep fetching data in a list , the user can display another fragment in the activity by selecting an item in the Spinner that displayed in the ActonBar. here is the code for the Activity public class HomeActivity extends SherlockFragmentActivity .....{ private class ListInfo { private String tag; private Class<?> clss; private Bundle bundle; private Fragment fragment; public ListInfo

FragmentPagerAdapter - unable to resolve superclass

孤街浪徒 提交于 2019-12-13 04:02:50
问题 I`m trying to use FragmentPagerAdapter but when trying to run it- there is an error: 02-22 22:48:53.328: W/dalvikvm(830): Unable to resolve superclass of Linfo/androidhive/tabsswipe/SlideActivity$FragmentPagerAdapter; (94) 02-22 22:48:53.328: W/dalvikvm(830): Link of class 'Linfo/androidhive/tabsswipe/SlideActivity$FragmentPagerAdapter;' failed 02-22 22:48:53.328: E/dalvikvm(830): Could not find class 'info.androidhive.tabsswipe.SlideActivity$FragmentPagerAdapter', referenced from method info

Android, instead of creating a new activity, it creates an activity with fragment

a 夏天 提交于 2019-12-13 03:59:40
问题 I am developing an Android app, and last week I updates a few packages (dont remember which ones exactly) using SDK Manager. After restarting Eclipse, whenever I create a new Activity (with used to contain only onCreate and onCreateOptionsMenu methods), it creates an Activity with those two methods, plus the folowing code : @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up

Does it ocurr serialization when passing objects between Activity's and Fragments

痴心易碎 提交于 2019-12-13 03:58:58
问题 I have a class Crop that isn't Serializable when it comes to passing her trough an intent to another Activity . But if it is from an Activity to a Fragment (trough Bundles ), there's no error and I can see the drawable object in the other side with no errors whatsoever. How can it be serializable in one case but not in the other ? public class Crop implements Serializable { private String specieHarvest; private String specieLocation; private String specieName; private Drawable img; } 回答1:

Loading activity in Fragment Code

﹥>﹥吖頭↗ 提交于 2019-12-13 03:38:58
问题 Can we load an activity (specifically in onCreateView) in fragment ? Instead of creating view by inflater, can we launch activity so it's events gets called ? For e.g. Instead of using "inflater.inflate(R.layout.tabactivity, null)", can we launch activity which uses "tabactivity" as layout ? 回答1: Unfortunately this is not possible. You must create a Fragment Activity that will be used to refer to any fragment you create. This is a good place to start: Fragments Examples 回答2: It's not possible