2013-02-20 40 views
2

我在彈出窗口中有一個RadioGroup。當我把setoncheckedchangelistener它會導致一個錯誤。這是我的代碼。錯誤說,這是不適用的參數(新化合物Button.OnCheckedChangeListener ..我不明白有人可以請幫我嗎?爲什麼setOnCheckedChangeListener在使用LayoutInflater的彈出窗口中不起作用?

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); 
    } 

我不知道什麼是錯的..請幫助。

+1

發佈您的錯誤日誌。 – RobinHood 2013-02-20 07:05:47

回答

5

相反進口

import android.widget.CompoundButton.OnCheckedChangeListener;

進口

import android.widget.RadioGroup.OnCheckedChangeListener;

同一問題討論here

+0

試過了 - 沒有變化。 – CodePrimate 2013-05-13 16:19:53

相關問題