开发者

How to set buttons in Android?

I have 7 to 8 buttons in my application.

Like this.

How to set buttons in Android?

How can I do this? I used:

LinearLayout ll = (LinearLayout)findViewById(R.id.searchdialog_layout);

ll.setOrientation(0);

Button btn = new Button(context);
btn.setBackgroundDrawable(getResources().getDrawable(R.drawable.bubble_layout));

btn.setPadding(4,0, 4, 0);

btn.setTextSize开发者_JAVA百科(14);

btn.setTextColor(Color.BLACK);

btn.setText("bubble" + " x");

ll.addView(btn) ;

But it didn't work.

Can anyone help?


 Button btnabout = (Button) findViewById(R.id.btnAbout);
    btnabout.setOnClickListener(new OnClickListener()
    {

        @Override
        public void onClick(View V) 
        {
            //do something
        }//end onClick          
    });//end button

traditional way of creating a button

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜