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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:32:22+00:00 2026-06-01T16:32:22+00:00

I’m trying to increase the size of a particular textview from within the app.

  • 0

I’m trying to increase the size of a particular textview from within the app. I would like to do it via a menu item selection but am having problems. I have tried the following:

@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
    // Create an options menu for the activity
    super.onCreateOptionsMenu( menu );

    incrseTxtMenu = menu.add( 0,4,0,"Increase Text Size" );
    incrseTxtMenu.setIcon( R.drawable.ic_menu_plus );
    incrseTxtMenu.setOnMenuItemClickListener( new MenuItem.OnMenuItemClickListener() 
    {
        @Override
        public boolean onMenuItemClick(MenuItem item) 
        {
            // handler.sendMessage( handler.obtainMessage() );
            TextView tempTxt = getTextView();
            tempTxt.setTextSize( 25 );

            return true;
        }
    });

    return true;
}

But this is throwing a null pointer exception. I also tried just using intro.setTextSize() but it throws the same error. How can I access the textview from within this menu item?

**Update

//Method used to fetch the textview
public TextView getTextView()
{
    return intro;
}

And the error from log cat:

AndroidRuntime FATAL EXCEPTION: main
java.lang.NullPointerException
at android.omni.Artist_activity$1.handleMessage( Artist_activity.java:32 )

Also btw – I’m trying to use a handler to update the GUI – am I correct in assuming that this is necessary right?

**Update 2 XML CODE

   <?xml version="1.0" encoding="utf-8"?>
    <ScrollView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id = "@+id/tab_one_top_level"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

      <LinearLayout
      android:orientation = "vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

      <TextView

    android:id = "@+id/faq_Intro"
    android:layout_width = "wrap_content"
    android:layout_height = "wrap_content"
    android:text = "@string/faq_Intro"
    android:typeface = "monospace"
    android:textStyle = "bold"
    android:paddingBottom = "12dp"

      />

      <TextView

    android:id = "@+id/faq_Intro_Info"
    android:layout_width = "wrap_content"
    android:layout_height = "wrap_content"
    android:text = "@string/faq_Intro_Info"
    android:textSize = "10dp"
    android:typeface = "monospace"
    android:textStyle = "bold"

      />

      </LinearLayout>
</ScrollView>

Any thoughts?

My Code Solution

@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
    // Create an options menu for the activity
    super.onCreateOptionsMenu( menu );

    incrseTxtMenu = menu.add( 0,1,0,"Increase Text Size" );
    incrseTxtMenu.setIcon( R.drawable.ic_menu_plus );

    decrseTxtMenu = menu.add( 0,2,0,"Decrease Text Size" );
    decrseTxtMenu.setIcon( R.drawable.ic_menu_negate );

    return true;

}

@Override
public boolean onOptionsItemSelected(MenuItem item) 
{
    // Increase size menu item
    if( item.getItemId() == 1 )
    {
        intro.setTextSize( myIntroSize += 5 );
        introInfo.setTextSize( myIntroInfoSize += 5 );

    }
    // Derease size menu item
    else if( item.getItemId() == 2 )
    {
        intro.setTextSize( myIntroSize -= 5 );
        introInfo.setTextSize( myIntroInfoSize -= 5 );
    }
    return true;
}

The onCreate() method simply initialises the textview as before. Oh and the values of myIntroSize and myIntroInfoSize can be whatever you want.

  • 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-01T16:32:23+00:00Added an answer on June 1, 2026 at 4:32 pm

    Please try the following code and tell me if it works. I don’t know what is wrong, it’s just based on a few hunches –

        @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        // Create an options menu for the activity
        super.onCreateOptionsMenu( menu );
    
        incrseTxtMenu = menu.add( 0,4,0,"Increase Text Size" );
        incrseTxtMenu.setIcon( R.drawable.ic_menu_plus );
        return true;
    }
    
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId() == 4){
             TextView tempTxt =  (TextView)findViewById( R.id.faq_intro);
                tempTxt.setTextSize( 25 );
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I would like to count the length of a string with PHP. The string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.