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 8283333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:41:54+00:00 2026-06-08T10:41:54+00:00

i want to build app with viewpager and display image and text from DB,

  • 0

i want to build app with viewpager and display image and text from DB, and i had a button to resize Text to Small,Medium,Big size, but my problem how to make that methode and call it? this is my code

Phrase.java

public void onCreate(Bundle savedInstanceState) {  
     setContentView(R.layout.phrase);  
     mViewPager = (ViewPager) findViewById(R.id.viewPager);  
     mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());  
     mViewPager.setAdapter(mMyFragmentPagerAdapter);

     text = (ImageView)findViewById(R.id.ibText);

     /* call db and store in arraylist */
     ....
}

private static class MyFragmentPagerAdapter extends FragmentPagerAdapter {  
    public MyFragmentPagerAdapter(FragmentManager fm) {  
         super(fm);  
    }  

    @Override  
    public Fragment getItem(int index) {  
         var = arrayphrase.get(index);
         phrase = var.phraseKey;
         title_phrase = var.titleKey;
         sound_id = var.indexkey;
         return PageFragment.newInstance(index,sound_id,phrase,title_phrase);
    }  

    @Override

    public void destroyItem(View container, int position, Object object) {
        // TODO Auto-generated method stub
        super.destroyItem(container, position, object);
    }

    @Override  
    public int getCount() {  

         return NUMBER_OF_PAGES;  
    }  
}  

CharSequence[] sizetext = {"Small", "Medium", "Big","Cancel"};
@Override
public void onClick(View v) {
      case R.id.ibText:
        AlertDialog.Builder listBuilder = new AlertDialog.Builder(Phrase.this);
        listBuilder.setItems(sizetext, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) 
            {

                   if(sizetext[item].equals("Big"))
                   {
                       sizeText=24;
                       onUpdateSize(sizeText);
                   }
                   else if(sizetext[item].equals("Medium"))
                   {
                       sizeText=20;
                       onUpdateSize(sizeText);
                   }
                   else if(sizetext[item].equals("Small"))
                   {
                       sizeText=16;
                       onUpdateSize(sizeText);
                   }
            }
        });
        AlertDialog alertList = listBuilder.create();
        alertList.show();
    break;
    }

PageFragment.java

    public class PageFragment extends Fragment { 
    public static PageFragment newInstance(int index,String sound, String phrase, String title_phrase) {

    PageFragment pageFragment = new PageFragment();
    Bundle bundle = new Bundle();
    bundle.putString("title_phrase", title_phrase);
    bundle.putString("sound", sound);
    bundle.putString("phrase", phrase);
    bundle.putInt("index", index);
    pageFragment.setArguments(bundle);
    return pageFragment;
}

@Override  
public void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
}  

@Override  
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  

    View view = inflater.inflate(R.layout.fragment, container, false);  
    ImageView imageView = (ImageView) view.findViewById(R.id.imageView1);  
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 2;
    options.inScaled = false;
    options.inPreferQualityOverSpeed=true;
    options.inJustDecodeBounds = false;
    options.inDither = false;
    Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(), Imgid[(int)(Math.random()*Imgid.length)], options);
    //imageView.setScaleType(ScaleType.FIT_XY);
    imageView.setImageBitmap(bitmap);

    ScrollView sv = (ScrollView)view.findViewById(R.id.scrollView1);
    LinearLayout.LayoutParams lp2= new LinearLayout.LayoutParams((int)(TorasanApp.device_width*0.7), (int) (TorasanApp.device_height*0.65),Gravity.CENTER);
    sv.setLayoutParams(lp2);
    sv.setBackgroundColor(Color.argb(20, 65, 65, 65));

    TextView tvdata = (TextView)view.findViewById(R.id.tvDetailPhrase);
    tvdata.setText(getArguments().getString("phrase"));

    TextView tvtitle = (TextView)view.findViewById(R.id.tvTitlephrase);
    tvtitle.setText(getArguments().getString("title_phrase"));
    return view;  
}  
}

you see in my Phrase when onclick i have onUpdateSize(sizeText) and i want call it to change TextView tvdata fontsize that was in PageFragment.java , so how to make that method and call it? because i try but still cant

  • 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-08T10:41:55+00:00Added an answer on June 8, 2026 at 10:41 am

    In your problem,

    You can have a Fragment instance in onClick method for which you want to update textview and from there you can call any method of that class(you have to create such method in Fragment class which will update textview.).

    For more understanding refer this link.

    in above link Step 10 contain the method calling(viewer.updateUrl(tutUrl);) to fragment class from FragmentActivity class

    And in step 8 defination of updateUrl method given which is in Fragment class

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

Sidebar

Related Questions

I want to build an app that is basically a subscription service for text
I want to build the app with a jpg image into a UILabel? (in
I want to build a desktop app where the size of both the window
i want build a photography app with effects . e.g. old images with brown
I want to build an app that works like custom URL app where I
I want build a sketch pad app on iPhone, I assume that this type
I want to build a flash app to let me and my users snap
I want to build a FB app which posts messages to the walls of
I want to build a REST web service on app engine. Currently i have
I want to build a Java web app and deploy it on EC2 .

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.