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

  • Home
  • SEARCH
  • 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 4626100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:22:11+00:00 2026-05-22T03:22:11+00:00

I’ve an app where my view is inflated from xml. It worked fine before

  • 0

I’ve an app where my view is inflated from xml. It worked fine before i tried to add a Horizontal slidebar, this component extends progressBar. I’ve added the progress bar code to my src folder in the correct package and declared it in my layout file within a relative layout.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="wrap_content" android:gravity="fill">
    <com.tecmark.TouchView android:layout_width="fill_parent" 
        android:layout_height="fill_parent"/>
    <Button android:text="Button" android:id="@+id/button1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" />
    <com.tecmark.HorizontalSlider android:id="@+id/slider" 
        android:indeterminateOnly="false" 
        android:progressDrawable="@android:drawable/progress_horizontal" 
        android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
        android:minHeight="30dip" android:maxHeight="30dip" 
        android:layout_width="fill_parent" android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true"/>
</RelativeLayout>

My view’s constructor includes the version that passes AttributeSet that is needed to inflate from xml.

public class TouchView extends View
{
    private File tempFile;
    private byte[] imageArray;
    private Bitmap bgr;
    private Bitmap bm;
    private Bitmap whitebm;
    private Paint pTouch;
    private int centreX = 1;
    private int centreY = 1;
    private int radius = 50;
    private HorizontalSlider slider;

    private static final String TAG = "*********TouchView";

    public TouchView(Context context)
    {
        super(context);
        // TouchView(context, null);
    }

    public TouchView(Context context, AttributeSet attr)
    {
        super(context, attr);

        Log.e(TAG, "******inside touchview constructor ");
        slider = (HorizontalSlider) this.findViewById(R.id.slider);
        Log.e(TAG, "******slider inflated*********** ");
        slider.setOnProgressChangeListener(changeListener);

        // ......get bitmap and process it code
    }// end of touchView constructor

    public void findCirclePixels()
    {
        // ..... changePixel code
    }// end of changePixel()

    @Override
    public boolean onTouchEvent(MotionEvent ev)
    {
        // ...... event code
        return true;
    }// end of onTouchEvent

    private OnProgressChangeListener changeListener = new OnProgressChangeListener()
    {
        @Override
        public void onProgressChanged(View v, int progress)
        {
            // TODO Auto-generated method stub
            setProgress(progress);
        }

        private void setProgress(int progress)
        {
            Log.e(TAG, "******slidebar clicked*********** ");
        }
    };

    @Override
    public void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);

        canvas.drawBitmap(whitebm, 0, 0, null);
        canvas.drawBitmap(bgr, 0, 0, null);
        canvas.drawCircle(centreX, centreY, radius, pTouch);
    }// end of onDraw
}

.

05-13 16:01:17.911: ERROR/AndroidRuntime(2433): Uncaught handler: thread main exiting due to uncaught exception
05-13 16:01:17.936: ERROR/AndroidRuntime(2433): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tecmark/com.tecmark.Jjilapp}: android.view.InflateException: Binary XML file line #9: Error inflating class com.tecmark.TouchView
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.os.Looper.loop(Looper.java:123)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.ActivityThread.main(ActivityThread.java:4363)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at java.lang.reflect.Method.invokeNative(Native Method)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at java.lang.reflect.Method.invoke(Method.java:521)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at dalvik.system.NativeStart.main(Native Method)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.tecmark.TouchView
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.Activity.setContentView(Activity.java:1622)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at com.tecmark.Jjilapp.onCreate(Jjilapp.java:30)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     ... 11 more
05-13 16:01:17.936: ERROR/AndroidRuntime(2433): Caused by: java.lang.reflect.InvocationTargetException
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at com.tecmark.TouchView.<init>(TouchView.java:59)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at java.lang.reflect.Constructor.constructNative(Native Method)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     ... 21 more
05-13 16:01:17.936: ERROR/AndroidRuntime(2433): Caused by: java.lang.NullPointerException
05-13 16:01:17.936: ERROR/AndroidRuntime(2433):     ... 25 more

.

Has anyone any ides why i’m getting this exception? Thanks matt.

  • 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-22T03:22:12+00:00Added an answer on May 22, 2026 at 3:22 am

    You have

    slider = (HorizontalSlider) this.findViewById(R.id.slider);
    

    initialized inside your TouchView class’ code, which I doubt to be correct, since the slider is not inside the TouchView, though it’s inside the Activity, in the same layout the TouchView is.

    You could remove the code from the TouchView‘s constructor, and put it inside a method public initSlider(HorizontalSlider slider).

    Then in your Activity‘s onCreate method, you access both the TouchView and the HorizontalSlider views as

    //TODO add id to your TouchView in xml!
    final TouchView touchView = (TouchView)findViewById(R.id.touchView); 
    final HorizontalSlider touchView = (HorizontalSlider)findViewById(R.id.slider); 
    
    touchView.initSlider(slider);
    

    And your TouchView‘s constructor will be splitted:

    public TouchView(Context context, AttributeSet attr)
    {
        super(context, attr);
        Log.e(TAG, "******inside touchview constructor ");
        // ......get bitmap and process it code
    }// end of touchView constructor
    
    public void initSlider(final HorizontalSlider slider)
    {
        Log.e(TAG, "******setting up slider*********** ");
        slider.setOnProgressChangeListener(changeListener);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
In order to apply a triggered animation to all ToolTip s in my app,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.