Starting Activity By Intent From Fragment Starts Blank Activity
I could not find an answer to my problem, so I make a new Question. I have an Android app with a TabLayout (+ ViewPagerAdapter) in my MainActivity and every Tab is a Fragment. Now
Solution 1:
Replace:
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.dialog_ride_details);
...
}
With:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_ride_details);
....
}
in your DetailsActivity class
refer http://developer.android.com/reference/android/app/Activity.html
Solution 2:
You need to return a View in the onCreateView method:
@Overridepublic View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroupv= (ViewGroup)inflater.inflate(R.layout.fragment_news,container,false);
...
return v;}
Solution 3:
How are you adding your fragment in Activity?
I can see that you are creating the view fragment and setting the activity layout,but I cannot see if your activity xml file has a <fragment name='fragmentClass'/>
tag or you are using a frame layout to add your fragment dynamically. To add fragment dynamically, you must use getSupportFragmentManager() and BeginTransaction to add your fragment in the Activity.
Please, add your activity xml file.
Solution 4:
Replace:
Intent intent = newIntent(con, OfferActivity.class);
getActivity().startActivity(intent);
With:
Intent intent = newIntent(getActivity(), OfferActivity.class);
startActivity(intent);
Post a Comment for "Starting Activity By Intent From Fragment Starts Blank Activity"