Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:13:06+00:00 2026-06-14T09:13:06+00:00

I create the following fragment in ActionBarMain.java FragMent1 fram1; FragmentTransaction fragMentTra = null; public

  • 0

I create the following fragment in “ActionBarMain.java”

    FragMent1 fram1;

FragmentTransaction fragMentTra = null;

public void onTabSelected(Tab tab, FragmentTransaction ft) {

    if (tab.getText().equals("Collection")) {
        try {
            rl.removeAllViews();
        } catch (Exception e) {
        }
        fram1 = new FragMent1();
        fragMentTra.addToBackStack(null);
        fragMentTra = getFragmentManager().beginTransaction().add(rl.getId(), fram1);
        fragMentTra.commit();

}

//And in here I create a new activity
         Intent intent = new Intent(this, AddBookActivity.class);
         startActivity(intent);

So naturally I should be able to perform the findFragmentByTag(fram1)

Now I am in the “AddBookActivity” and have added a new item to an arraylist that fram1 prints out in a simple_list_item_1 so now I want to refresh fram1, how do I do that in AddBookActivity??

//AddBookActivity.java
@Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.addBook:
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                Fragment newFragment = new FragMent1();
                FragmentTransaction transaction = getFragmentManager().beginTransaction();
                //How do I find out the fragment id from findFragmentByTag(fram1)????
                transaction.replace(R.id.your_fragment_id, newFragment);//Whats the id, I have the Tag that is fram1
                transaction.addToBackStack(null);
                transaction.commit();
                return true; 
            case R.id.cancel:
                super.finish(); 
                return (true);

            }

            return (super.onOptionsItemSelected(item));
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:13:07+00:00Added an answer on June 14, 2026 at 9:13 am

    findFragmentByTag takes a String as a parameter, not a Fragment

    so you would use

    fragMentTra = getFragmentManager().beginTransaction().add(rl.getId(), fram1, "fram1");
    

    to add, and replace using

    transaction.replace(R.id.your_fragment_id, newFragment, "fram1");
    

    to find the fragment, use

    findFragmentByTag("fram1");
    

    Whether that will update your list is another matter, since the code you posted does not address that.

    EDIT:

    Your Activity can load multiple Fragments, and therefore the Activity layout will depend on the screen size. Simplest use is that it is only large enough for one Fragment. This Fragment is a FragmentList or it contains a ListView. The list requires an Adapter to bind the data to the list. Simple example is a ArrayAdapter of type String e.g. ArrayAdapter<String>. You assign the ListView to use the ArrayAdapter as its data source. You can then change the ArrayAdapters underlaying data (ArrayList<String> or String[]) directly (requires the adapter to be notified of the change) or via the adapter itself. More complex views can be achieved by extending a adapter class.

    I suggest looking at ListView and FragmentList SDK samples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I create following the Servlet 3.0 specification a web application fragment how can
I create the following attribute: public class SpecificDataTypeAttribute : DataTypeAttribute { public SpecificDataType(DataType dataType,
I used the following create statement: CREATE TABLE `subscr` ( `id` int(11) NOT NULL
I am following following link to create fragment in anadroid http://www.vogella.com/articles/Android/article.html#fragments but it always
Please consider the following code fragment: import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.reflect.InvocationTargetException;
I'm trying to create a fragment class following from this: And they give you
I get the following error while trying to create a ListFragment in a tab.
I'm trying to create a list fragment activity like this : public class FluxListeFragment
i'm trying to create following layout: http://jsfiddle.net/BTuMH/1/ but without setting the width, like: http://jsfiddle.net/yuGyg/
The following CREATE TABLE statement to partition a table works as expected, without error.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.