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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:12:19+00:00 2026-05-31T06:12:19+00:00

I try using the auto re-size stated at Auto Scale TextView Text to Fit

  • 0

I try using the auto re-size stated at Auto Scale TextView Text to Fit within Bounds but somehow i try to implement it as shown:

AutoResizeTextView test;
Boolean fit = true;
@Override
public void onCreate(Bundle savedInstanceState) 
{   
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    WindowManager winMan = (WindowManager) getBaseContext().getSystemService(Context.WINDOW_SERVICE);
    test =  new AutoResizeTextView(this);
    if (winMan != null)
    {
        int orientationS = winMan.getDefaultDisplay().getOrientation();   
        if (orientationS == 0) 
        {
            test = (AutoResizeTextView)findViewById(R.id.testing123);
            test.setTextColor(R.color.red); 
        test.resizeText();
            // Portrait
            setContentView(R.layout.content_page);          
            //addListenerOnButton();
        }

But it always end up with following error whenever I wanna edit any text/ try to edit anything related to the text. Eg, test.resizeText();

03-13 08:13:38.281: W/dalvikvm(2002): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-13 08:13:38.292: E/AndroidRuntime(2002): FATAL EXCEPTION: main
03-13 08:13:38.292: E/AndroidRuntime(2002): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.mypackage.ContentPage}: java.lang.NullPointerException
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.os.Looper.loop(Looper.java:123)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at     java.lang.reflect.Method.invokeNative(Native Method)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at java.lang.reflect.Method.invoke(Method.java:521)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at dalvik.system.NativeStart.main(Native Method)
03-13 08:13:38.292: E/AndroidRuntime(2002): Caused by: java.lang.NullPointerException
03-13 08:13:38.292: E/AndroidRuntime(2002):     at com.mypackage.ContentPage.onCreate(ContentPage.java:41)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-13 08:13:38.292: E/AndroidRuntime(2002):     ... 11 more
03-13 08:13:40.142: I/Process(2002): Sending signal. PID: 2002 SIG: 9

new log after implementing imrankhan’s codes

03-13 08:13:38.281: W/dalvikvm(2002): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-13 08:13:38.292: E/AndroidRuntime(2002): FATAL EXCEPTION: main
03-13 08:13:38.292: E/AndroidRuntime(2002): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.mypackage.ContentPage}: java.lang.NullPointerException
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.os.Looper.loop(Looper.java:123)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at java.lang.reflect.Method.invokeNative(Native Method)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at java.lang.reflect.Method.invoke(Method.java:521)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at dalvik.system.NativeStart.main(Native Method)
03-13 08:13:38.292: E/AndroidRuntime(2002): Caused by: java.lang.NullPointerException
03-13 08:13:38.292: E/AndroidRuntime(2002):     at com.mypackage.ContentPage.onCreate(ContentPage.java:41)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-13 08:13:38.292: E/AndroidRuntime(2002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-13 08:13:38.292: E/AndroidRuntime(2002):     ... 11 more
03-13 08:13:40.142: I/Process(2002): Sending signal. PID: 2002 SIG: 9

mpeerman’s code logcat

03-13 08:44:17.112: E/AndroidRuntime(2142): FATAL EXCEPTION: main
03-13 08:44:17.112: E/AndroidRuntime(2142): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.mypackage.ContentPage}: java.lang.ClassCastException: android.widget.TextView
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.os.Looper.loop(Looper.java:123)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at java.lang.reflect.Method.invokeNative(Native Method)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at java.lang.reflect.Method.invoke(Method.java:521)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at dalvik.system.NativeStart.main(Native Method)
03-13 08:44:17.112: E/AndroidRuntime(2142): Caused by: java.lang.ClassCastException: android.widget.TextView
03-13 08:44:17.112: E/AndroidRuntime(2142):     at com.mypackage.ContentPage.onCreate(ContentPage.java:42)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-13 08:44:17.112: E/AndroidRuntime(2142):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-13 08:44:17.112: E/AndroidRuntime(2142):     ... 11 more

contentpage.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/content_p" >
    <TextView
    android:id="@+id/testing123"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="HELLO"/>
</LinearLayout>
  • 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-05-31T06:12:21+00:00Added an answer on May 31, 2026 at 6:12 am

    try this

    AutoResizeTextView test;
    Boolean fit = true;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {   
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    WindowManager winMan = (WindowManager) getBaseContext().getSystemService(Context.WINDOW_SERVICE);
    setContentView(R.layout.content_page); //Set ContentView Before accessing R.id.testing123 parent layout    
    test =  new AutoResizeTextView(this);
    if (winMan != null)
    {
        int orientationS = winMan.getDefaultDisplay().getOrientation();   
        if (orientationS == 0) 
        {
        //setContentView(R.layout.content_page);  maybe here
            test = (AutoResizeTextView)findViewById(R.id.testing123);
            test.setTextColor(R.color.red); 
        test.resizeText();
            // Portrait
    
            //addListenerOnButton();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try using evt.parent.attr(id) inside jsddm_close, but it doesn't work. <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js></script> <script
When I try using a Name=id and\or x:name=id I get a compiler error: The
Why do i get an error when I try using _ instead of using
Following the advice of wcoenen, I've decided to try using registration-free COM. This works
Out of habit I've been using try/catch blocks in my application code for all
What kind of performance implications are there to consider when using try-catch statements in
I am writing a stored procedure where i m using try catch block. Now
Recently, I made a post about the developers I'm working with not using try
I have a form that I am using to try and update a field
I have a DAO class which I'm using to try select/update/insert with hibernate and

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.