为什么不setOnCheckedChangeListener在使用LayoutInflater弹出一个工作吗? [英] Why setOnCheckedChangeListener not working in a popup that uses LayoutInflater?
问题描述
我有一个弹出一个RadioGroup中。当我把它setoncheckedchangelistener导致错误。这里是我的code。错误说,这是不适用的参数(新复方Button.OnCheckedChangeListener ..我不明白的可以有人请帮助我吗?
I have a RadioGroup in a popup. When i put setoncheckedchangelistener it causes an error. here's my code. The error says that it is not applicable to the arguments (new Compound Button.OnCheckedChangeListener.. i don't understand can somebody pls help me?
private void showPopupSeat(final Activity context)
{
int popupWidth = 500;
int popupHeight = 650;
// Inflate the popup_layout.xml
LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popupseat);
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.seat_dimension, viewGroup);
RadioGroup rg = (RadioGroup) layout.findViewById(R.id.rg1);
final RadioButton rb1 = (RadioButton) layout.findViewById(R.id.option1);
final RadioButton rb2 = (RadioButton) layout.findViewById(R.id.option2);
final RadioButton rb3 = (RadioButton) layout.findViewById(R.id.option3);
rg.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId) {
}
});
final PopupWindow popupseat = new PopupWindow(context);
popupseat.setContentView(layout);
popupseat.setWidth(popupWidth);
popupseat.setHeight(popupHeight);
popupseat.setFocusable(true);
// Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
int OFFSET_X = 30;
int OFFSET_Y = 260;
// Clear the default translucent background
popupseat.setBackgroundDrawable(new BitmapDrawable());
// Displaying the popup at the specified location, + offsets.
popupseat.showAtLocation(layout, Gravity.CENTER, 0, 0);
}
我不知道什么是错的..请帮助。
i dont know what is wrong.. pls help.
推荐答案
相反,进口
进口android.widget.CompoundButton.OnCheckedChangeListener;
导入
进口android.widget.RadioGroup.OnCheckedChangeListener;
同样的问题讨论<一个href=\"https://groups.google.com/forum/?fromgroups=#!topic/android-developers/PemtaXI9tpg\">here.
这篇关于为什么不setOnCheckedChangeListener在使用LayoutInflater弹出一个工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!