How can I set the width of a button during run time?
<p>I want to set the button width during run time and I want it to be equal to 50% of the display width.
I used the following but I have a problem "nothing appears in emulator" and says
"Process stopped unexpectedly. Please try again"
.java
    public class experiment extends Activity{</p>

<pre><code>    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Display display = getWindowManager().getDefaultDisplay(); 
        int width = display.getWidth();
        int height = display.getHeight();
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        Button btn = (Button) findViewById(R.id.btnmarwa);
        btn.setWidth(width/2);      
        setContentView(R.layout.emailpopup);
    }
}
</code></pre>

<p>When I commented this line
    btn.setWidth(width);<br>
There is no errors and the layout appears, So where to set the new width to the button in .java file??</p>
