android-fragmentactivity

refresh a fragment from its parent activity

无人久伴 提交于 2019-11-26 21:46:02
问题 I have almost the exact same problem as this question here: Android, How to restart/refresh a fragment from FragmentActivty? I'm trying to call the a method of a ListFragment from the parent FragmentActivity . However, I'm using the template Swipe + Fixed Tabs generated by eclipse. I tried calling getSupportFragmentManager().findFragmentById(R.id.myfragment) but the return value is always null. I'm guessing this might be a problem because I did not define myfragment anywhere in my app. But I

Bind service to FragmentActivity or Fragment?

China☆狼群 提交于 2019-11-26 20:15:55
问题 Is it better to bind service to FragmentActivity : bindService(Intent, ServiceConnection, int); or to Fragment : getActivity().bindService(Intent, ServiceConnection, int); What is better practice? 回答1: Is it better to bind service to FragmentActivity... or to Fragment They are the same as you have them written here. getActivity() is not a Fragment -- it is a method that returns the Activity . You cannot call bindService() on a Fragment . What is better practice? Neither. Bind to the

What is the difference between Fragment and FragmentActivity?

偶尔善良 提交于 2019-11-26 19:15:52
My question is apart from the obvious inheritance differences, what are the main differences between Fragment and FragmentActivity ? To what scenarios are each class best suited? I'm trying to get an understanding of why both of these classes exist... Gunnar Karlsson A Fragment is a section of an Activity , which has: its own lifecycle receives its own input events can be added or removed while the Activity is running. A Fragment must always be embedded in an Activity . Fragments are not part of the API prior to HoneyComb (3.0). If you want to use Fragments in an app targeting a platform

Start an activity from a fragment

与世无争的帅哥 提交于 2019-11-26 18:24:35
I have 2 fragments with on both fragments a button. When I press the button I'd like to start a new Activity. But I can't get it to work. The error I'm getting: ERROR here: Type mismatch: cannot convert from mFragmentFavorite to Fragment What am I doing wrong? MyFragmentPagerAdapter import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; public class MyFragmentPagerAdapter extends FragmentPagerAdapter{ final int PAGE_COUNT = 3; /** Constructor of the class */ public MyFragmentPagerAdapter(FragmentManager fm) {

Android - Activity vs FragmentActivity? [duplicate]

半城伤御伤魂 提交于 2019-11-26 18:21:24
This question already has an answer here: Difference between Activity and FragmentActivity 2 answers I am new in Android. I want to build an app with tab format. I found many documentation where Activity has been used. Also in many cases have used FragmentActivity . I am not sure which will be better to start. Please suggest me should I use Activity or FragmentActivity to start development in tab format? ray ianhanniballake is right. You can get all the functionality of Activity from FragmentActivity . In fact, FragmentActivity has more functionality ). Using FragmentActivity you can easily

“Failure Delivering Result ” - onActivityForResult

…衆ロ難τιáo~ 提交于 2019-11-26 18:11:51
I have a LoginActivity (User Logs in). It is basically its own Activity that is themed like a dialog (to appear as if a dialog). It appears over a SherlockFragmentActivity . What I want is: If there is a successful login, there should be two FragmentTransaction 's to update the view. Here is the code: In LoginActivity , if successful login, setResult(1, new Intent()); In SherlockFragmentActivity : @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == 1) { LoggedStatus = PrefActivity

TabHost with Fragments and FragmentActivity

泪湿孤枕 提交于 2019-11-26 17:20:06
I'm working on an Android App and I want to use 3 tabs for navigation using Fragments for each tab, but I don't know how to create the structure for doing it. I want to add each fragment separately because each one is different, but I don't know where to add them in FragmentActivity. I have these files. tabs_layout.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="match_parent" android:layout_width="match_parent"> <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height=

How can I access getSupportFragmentManager() in a fragment?

风流意气都作罢 提交于 2019-11-26 17:16:44
I have a FragmentActivity and I want to use a map fragment within it. I'm having a problem getting the support fragment manager to access it. if (googleMap == null) { googleMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map1)).getMap(); // check if map is created successfully or not if (googleMap == null) { Toast.makeText(getApplicationContext(), "Sorry! unable to create maps", Toast.LENGTH_SHORT) .show(); } } // create marker MarkerOptions marker = new MarkerOptions().position( new LatLng(latitude, longitude)).title("Hello Maps "); CameraPosition cameraPosition

refresh fragment UI from fragmentActivity

瘦欲@ 提交于 2019-11-26 16:42:44
I want to change a ImageView in fragment(that create in code), from FragmentActivity. (there is no fragment and tag in XML). MainActivity that extends from FragmentActivity and implements from GooglePlayServicesClient.ConnectionCallbacks: ... FragmentAdapter mAdapter; ViewPager mPager; ... public void onCreate(Bundle savedInstanceState){ ... FragmentManager fm = getSupportFragmentManager(); mAdapter = new FragmentAdapter(fm); mPager.setAdapter(mAdapter); ...} @Override public void onConnected(Bundle connectionHint){ //*** I want to change a ImageView on Fragment1 here } FragmentAdapter that

Manage toolbar&#39;s navigation and back button from fragment in android

随声附和 提交于 2019-11-26 15:41:22
问题 All of my fragments are controlled through ActionBarActivity (mainActivity), inside mainActivity a DrawerLayout is implemented and all the child fragments are pushed through drawerLayout's list item click. The problem that I'm facing is after pushing a fragment through drawerLayout I want to change the drawer icon into back icon of ToolBar so that user can navigate to previous fragment and to handle the callback of android.R.id.home either inside the same fragment or inside the mainActivity.