Wednesday, September 16, 2009

hi all...,

In android i have created a button...bt nw i hav to create another button..tell me hw to create using java code...my code is.

package pack.button;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.ViewGroup.LayoutParams;
import pack.button.R;

public class SimpleButton extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = new Button (this);
b.setText("Press Me!");
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
setContentView(b, lp);
}
}

No comments:

Post a Comment