开发者

How to set buttons in Android?

开发者 https://www.devze.com 2023-01-15 17:38 出处:网络
I have 7 to 8 buttons in my application. Like this. How can I do this? I used: LinearLayout ll = (LinearLayout)findViewById(R.id.searchdialog_layout);

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

精彩评论

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