Sorry for my newbie Question, i just cannot find the answer from google and stackoverflow.. i just start learning for android, wish can build a good base for android knowledge. I wondering which i should use in the following if i create toast.maketext in fragment. getActivity() or getAcitivity().getApplicationContext()?
i did try both, it works well..
In my app, I have a ListFragment:
Fragment fragment = new MyFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(resId, fragment, "tag");
transaction.addToBackStack("tag");
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.commit();
When user taps Refr
I have the following problem:
My app consists of several fragments that are dynammicly added. There is one fragment with a push button and an textedit (called 'fragA').
If I click the push button I want to show an different fragment with some text (called 'fragB').
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
Toast.makeText(MainActivity.appContext, "Reselected!", Toast.LENGTH_LONG).show();
}
My application closes and throws a Null Pointer Exception when i re-select the actionbar again. The error seems to be happening inside the above method.
I have a following Fragment:
public class FragmentSocial extends Fragment implements ActionBar.TabListener, OnClickListener
{
private Fragment mFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().setContentView(R.layout.fragment_social);
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// relevant co
I have an EditText view in my MainActivity that the user can input a url. This MainActivity also contains a fragment which will hold a WebView.
I have it set up so that when the fragment is displayed the url will load in the WebView.
I have following issue with Android compatibility package fragments.
There is following hierarchy of fragments:
A(login) -> B(dashboard) -> C(details)
Login fragment is added with function:
private void addFragment(Fragment f) {
FragmentTransaction ft = mFragmentManager.beginTransaction();
ft.replace(R.id.main_content, f);
ft.commit();
}
After successfull login dashboard is added
In my application , on a button click I am creating a Toast as -
Toast.makeText(context,"Please Enter Username",Toast.LENGTH_SHORT).show();
But when someone clicks on the button 5-6 times and closes the application, or goes on another screen, it still keeps on showing the Toast for sometime on another screen also.
I am sorry, this question is for those of you working on Eclipse with access to the ApiDemo sample codes.
Specifically, I am trying to base a fragment activity on the sample called FragmentLayout
The following code is problematic for me
(you can find the full code in ApiDemo FragmentLayout.java, ShowDetails() method):
// Execute a transaction, replacing any existing fragment