android-fragmentactivity

How can I put titles in ViewPager using fragments?

纵然是瞬间 提交于 2019-11-28 18:03:19
I am using ViewPager to allow user to swipe between fragments. How can I add a the title of each fragment to the screen? package com.multi.andres; import java.util.List; import java.util.Vector; import com.viewpagerindicator.TitlePageIndicator; import com.viewpagerindicator.TitleProvider; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; public class ViewPagerFragment extends FragmentActivity

Fragment activity communication by passing Context object to onAttach()

不问归期 提交于 2019-11-28 14:46:50
Im trying to implement fragment to activity communication. Went through android developer doc where an Activity object is passed to onAttach life cycle and set up the Fragment-Activity communication. This documentation asks to pass Context object instead of Activity. I replaced all the Activity objects by Context objects in the life cycle method onAttach. But it is throwing a NullPointerException while calling the method of the interface from Fragment. @Override public void onAttach(Context context) { super.onAttach(context); try { colourChangerInterface = (ColourChangerInterface) context; }

Android: NullPointerException Unable to load database into listview within a fragment

点点圈 提交于 2019-11-28 12:20:19
问题 I've been searching for a while trying to find how to populate a listview with information from the MySQLite database. Now when I think I finally found some information I come up with NullPointers. Here is my code (HomeFragment.java) : package zygs.com.seniorproject.fragments; import android.app.Fragment; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View

Android Google Maps API “Error inflating class fragment” [duplicate]

岁酱吖の 提交于 2019-11-28 12:18:27
问题 This question already has answers here : After Google Play Service update to version 13 I got an error (8 answers) A required meta-data tag in your app's AndroidManifest.xml does not exist. (9 answers) Closed 5 years ago . I'm new to Android Development, I've started with something simple, just displaying a map centered on where I live. I've been trying many things to solve my problem, without any success, I'll leave here my code and the error log. I'll be really grateful if you can help me

Communication between Fragments

家住魔仙堡 提交于 2019-11-28 11:40:01
I have default Master-Detail flow, which was created automatically when creating new project. My question is. When I add a button to detail side. Is there a way to update my list side by pressing that button ? In other words, can ItemDetailFragment and ItemListFragment communicate ? Yes just communicate through the activity with a listener. Your activity: public class MyActivity extends FragmentActivity implements OnFragmentClickListener { @Override public void OnFragmentClick(int action, Object object) { switch(action) { } } } The listener class: public interface OnFragmentClickListener {

Android non-UI Fragment usage [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-11-28 09:43:09
This question already has an answer here: What is the use case for a Fragment with no UI? 5 answers I am going through the Android documentation on Fragments . The layout that defines the UI of a Fragment may be defined in the layout of the Activity, in a separate .xml file or not at all. According to the documentation you can also use a fragment to provide a background behavior for the activity without presenting additional UI. Why would I need to use another Fragment to add functionality to an Activity instead of defining a few more functions within the Activity? Would such a non-UI Fragment

NullPointerException: Attempt to read from field 'int android.app.Fragment.mContainerId' on a null object reference

别说谁变了你拦得住时间么 提交于 2019-11-28 07:42:17
问题 Having some interesting issue with transaction on fragments on Android Lollipop ONLY. Crash happens when i go back and remove previously added fragment. Here is stacktrace : FATAL EXCEPTION: main Process: com.parkme.consumer, PID: 15560 java.lang.NullPointerException: Attempt to read from field 'int android.app.Fragment.mContainerId' on a null object reference at android.app.BackStackRecord$1.onPreDraw(BackStackRecord.java:1131) at android.view.ViewTreeObserver.dispatchOnPreDraw

How do I resolve the authentication message that keeps popping up in a webview?

送分小仙女□ 提交于 2019-11-28 06:38:27
问题 I have a webview with authentication, in which the authentication message keeps popping up for the webview fragment when called.The authentication popup is the fault code 410 (already signed in: sign in/cancel) message, How do I pass my cookies for the session id to be maintained? Any clues? thanks! P.S: Please explain programmatically with respect to my code wherever possible as it's hard to understand when you explain without code. Here is my code for the given fragment: public class

Android: How to call Fragment class from activity using Intent

孤街醉人 提交于 2019-11-28 04:33:57
问题 I am trying to call a Fragment class from Activity using Intent. Is it possible to implement. Please provide your views. 回答1: Fragment needs to be hosted by a FragmentActivity , you can't add a fragment via an Intent . You need to create a FragmentManager to add your fragment in the FragmentActivity (or call another FragmentActivity via an Intent and add your fragment on it). See this topic for more information: Add a Fragment to an Activity at Runtime. 回答2: Fragment TargetFragment=new target

FragmentTabHost & Fragments - How do I pass data between tabs?

南笙酒味 提交于 2019-11-28 04:22:04
问题 I have a MainActivity (FragmentActivity) that has a FragmentTabHost. public class FragmentTabs extends FragmentActivity { private FragmentTabHost mTabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs); mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); mTabHost.addTab(mTabHost.newTabSpec("classA").setIndicator("Class