android-fragmentactivity

setText from inside a fragment

一世执手 提交于 2019-12-24 11:22:21
问题 I run a setText command inside of a fragment activity to try and set the text of a textView in the parent activity, but it's not working. Any ideas? TextView text = (TextView) getView().findViewById(R.id.status); text.setText("Text from a fragment"); I don't get an error in eclipse, but I get a null pointer exception during runtime. Of course it happens at the line where I setText. Any ideas on how to do this? 回答1: Yes your NPE will probably be because R.id.status is probably not defined in

How to Create Forground Service Never Stop when Application is Inactive

百般思念 提交于 2019-12-24 06:35:40
问题 I have created one application in which I want to start service First time open the application.when application is in foreground Every 5 or 10 minutes Local Notification received.but Notification received only When Application Active or Recent app.When Clear the Recent app Notification Does't receive.I wanted this service to keep running on the device. Sample code of created service and start services: Start the service: Intent i=new Intent(MainActivity.this,MyService.class); startService(i)

Force tablet to be in landscape mode

天涯浪子 提交于 2019-12-24 05:49:49
问题 Is there a way to force the tablet to be in landscape mode as default orientation when the user start's my app. Is there a way to do this with theming or something like that, so the user doent see orientation change when he is starting the app? Note: the same app is (should be) in portrait mode for phones For now I have a boolean values folder refs.xml(both values and values-large) with different value for tablet and phone, but the user can see that the app is rotating Code: public static

Android - How to handle orientation of FragmentActivity?

做~自己de王妃 提交于 2019-12-24 04:01:36
问题 I am currently using the Sherlock package and the view indicator package in my application to create a view pager with the titles at the top and then the action bar over that. For the most part it works OK however I have noticed that invalidateOptionsMenu() stops working after a screen orientation change. When my app loads it works fine until I rotate the device to landscape mode, from then on the invalidateOptionsMenu() call never invokes the onCreateOptionsMenu(Menu menu) method. It's a

class not found exception android for fragment activity

一曲冷凌霜 提交于 2019-12-24 03:25:04
问题 I am working on fragment activity to work on gingerbread OS. when I am trying to run the application on gingerbread emulator the application is getting forced close due to ClassNotFound error. I am providing my main fragment activity code below A peace of help would be appreciable. package com.example.android.effectivenavigation; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.ActionBar; import android.app.FragmentTransaction; import android.os

Not able to update Fragment UI from onActivityResult

☆樱花仙子☆ 提交于 2019-12-24 00:56:17
问题 I'm working on an app in which has a class that extends FragmentActivity. In the onResume() method I was calling a class for which I am sending the reference of this fragmentactivity and in that class I'm replacing it with another fragment. In that Fragment I'm dynamically adding the layout , but when I click on the button I'm Calling startActivityForResult() which in turn receives results in OnActivityResult() in which I'm trying to update the text of EditText , but it is not happening. When

setCurrentItem of nested viewpager

浪尽此生 提交于 2019-12-23 23:27:49
问题 I have a ViewPager nested in a fragment, and when the device changes orientation I'd like to save and restore which page the ViewPager was on. I'm currently doing this: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mViewPager = (ViewPager) inflater.inflate(R.layout.activity_albumpicker, container, false); // Create the adapter that will return a fragment for each of the three // primary sections of the activity.

How to avoid adding same fragment to stack

老子叫甜甜 提交于 2019-12-23 08:45:08
问题 I need some help. em adding fragment to activity this way. problem is on each call of openFragment it create fragment and add. which is obvious. Question: what modification i do, so it can add fragment only once. on the next call with same fragment tag it will do nothing. case: press button first time it add fragment and shows. i press again same button it response nothing. public static void openFragment(Activity activity, Fragment fragment) { FragmentManager fragmentManager = (

How to avoid adding same fragment to stack

主宰稳场 提交于 2019-12-23 08:44:24
问题 I need some help. em adding fragment to activity this way. problem is on each call of openFragment it create fragment and add. which is obvious. Question: what modification i do, so it can add fragment only once. on the next call with same fragment tag it will do nothing. case: press button first time it add fragment and shows. i press again same button it response nothing. public static void openFragment(Activity activity, Fragment fragment) { FragmentManager fragmentManager = (

Fragment Onclick Listener

感情迁移 提交于 2019-12-23 05:02:31
问题 I am using Bottom Navigation Activity in my project. Which contains following activities. I am using kotlin Language. I am not sure how to route from one fragment to another fragment in bottom navigation activity. Any help is appreciated. Code: https://github.com/joshvapeter/KotlinBottomNavigationNew Activies 1)One Main Activity 2)Two Fragments 3)Two Adapter Class 4)Two Layout files Expectation When I click the Fragment One Recycler View Item then It need to automatically route it to Fragment