Force close when creating progressbar programmatically


angrycat

Members
Jul 21, 2011
1
11
Hi, I'm the developer of Beaver, a tabbed browser on the android market.

MIUI users are getting force closes when trying to run my app, and I've tracked down the bug to the creation of a horizontal progress bar. Android complains that a layout height wasn't specified and therefore force closes. I'm guessing that MIUI overrides the standard android themes. Here's the code I use to create my progressbar: you can use it to replicate this issue:

You can also see this issue when running the lite version of the app:

Code:
        RelativeLayout mRelative = new RelativeLayout(this);
        mRelative.setGravity(Gravity.FILL);
        mRelative.setBackgroundColor(Color.parseColor("#000000"));
        
        RelativeLayout.LayoutParams b = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, 20);
        loadingProgressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
        loadingProgressBar.setId(678);
        loadingProgressBar.setMax(100);
        loadingProgressBar.setBackgroundColor(Color.parseColor("#696969"));
        b.addRule(RelativeLayout.CENTER_HORIZONTAL);    
        mRelative.addView(loadingProgressBar, b);

The standard android.R.attr.progressBarStyleHorizontal specifies minheight and minwidth attributes, possibly that's what the issue is?
 
I know very little about Java programming, but I don't think it's your program, because it seems you have the position of the progress bar set at a relative position, so it should accustome with the height and the width of the screen resolution, correct..?
 
Hi, I have the same problem with my app. Since I added a progress bar people that have miui have started complaining about FC.

stackTrace:java.lang.RuntimeException: Unable to resume activity {org.blockdroidpro/org.blockdroid.View.ShowResult}: java.lang.RuntimeException: <internal>: You must supply a layout_height attribute.

Without the progress bar (progressBarStyleHorizontal) everything works fine.
 
hello
it is a known issue with MIUI and horizontal progress bar
there is an app i really like wich uses it but sadly on MIUI i cant use it hehe
would LOVE to find a way to get it working
this topic should be STICKY !