-3
View view = View.inflate(this, R.layout.card_scroll_item, null);
viewFlipper.addView(view);
Button creditbtn = (Button) view.findViewById(R.id.credit_button);
creditbtn.setBackgroundResource(carddraw[i]);
TextView txtname = (TextView) view.findViewById(R.id.credit_type);
txtname.setText("Visa");
TextView txtnumber = (TextView) view.findViewById(R.id.credit_number);
txtnumber.setText(creditnum[i]);
txtnumber.setTypeface(tf);`

I had used this code how to get on click event on each button

4

2 回答 2

0
1. Implement the onClickListener interface in your activity class.

2. set creditbtn.setOnclickListener(this);

3. 

@Override
public void onClick(View view){

int id = view.getId();

switch(id){

case R.id.credit_type:

// do your stuff

break;

}

}

希望这会有所帮助

于 2013-05-31T09:08:19.407 回答
0

首先你需要为你的按钮设置 onClick 监听器,像这样

creditbtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // Do your actions here             
        }
    });

其次,您需要先研究,然后提出问题:)

希望这对您有所帮助并享受您的工作。

于 2013-05-31T09:05:49.810 回答