【发布时间】:2012-07-14 17:25:45
【问题描述】:
您好,我正在尝试为我的按钮购买设置内容描述,当我尝试访问它时,返回给我的值为 null。
这是按钮的代码。
//This is the button of the payment.
ImageButton make_pay = new ImageButton(this);
make_pay.setBackgroundResource(R.drawable.add_product);
makePay.addView(make_pay);
makePay.setContentDescription("Precio");
这是我用来访问的代码:
make_pay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View makepay) {
LinearLayout wrap_area = (LinearLayout)findViewById(R.id.division2);
TextView test = new TextView(FrontActivity.this);
wrap_area.addView(test);
if (makepay.getContentDescription() == null){
test.setText("Precio:1");
}else{
test.setText(makepay.getContentDescription().toString());
}
});
}
【问题讨论】:
标签: android android-widget android-view