混淆android检查列表框

时间:2014-02-11 07:14:08

标签: android

我想在选择单选按钮后使用checklistbox实现产品列表。 我想将chekclistbox显示为对话框。我的产品列表数据来自sqllite。 需要实现适配器类来显示checklistbox的数据,还是可以直接在alertDialog中实现checklistbox数据。请告诉我。

在mainActivity中

public RadioGroup.OnCheckedChangeListener setOnCheckedChangeListener = new OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        rdoPCode = (RadioButton) findViewById(checkedId);
        switch (checkedId) {
        case R.id.rdoAll:
            Toast.makeText(context, rdoPCode.getText(), Toast.LENGTH_SHORT)
                    .show();
            break;
        case R.id.rdoCustom:
            Intent localIntent = new Intent(MainActivity.context,
                    ProductListChkActivity.class);
            MainActivity.context.startActivity(localIntent);                
            break;
        }
    }
};

在ProductListChkActivity

public class ProductListChkActivity extends Activity {

private static Button button_selectall;
private static Button button_unselectall;
private static CheckBox chkProductCode;

private static CashSaleProductLogic _sellProductLogic;
public static List<CashSaleProductInfo> _SaleProductInfo;

public static ListView lvlchkPrdlist;
private Button btnSelectAll, btnUnSelectAll;

// For chk productcode
private static ProductListChkAdapter _ProductListChkAdapter;
Context context;

@Override
protected void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    setContentView(R.layout.productinofchk);

    context = this;

    init();

    ProductCodeChk();
}

private void init() {
    button_selectall = (Button) this.findViewById(R.id.button_selectall);
    button_unselectall = (Button) this
            .findViewById(R.id.button_unselectall);
    chkProductCode = (CheckBox) this.findViewById(R.id.chkProductCode);
    lvlchkPrdlist = (ListView) this.findViewById(R.id.lvlchkPrdlist);

    _sellProductLogic = new CashSaleProductLogic(this);
    _SaleProductInfo = _sellProductLogic.getAllsellProductDataLogic();
}

protected void ProductCodeChk() {
    try {

        _ProductListChkAdapter = new ProductListChkAdapter(context,
                _SaleProductInfo, 1);
        this.lvlchkPrdlist.setAdapter(_ProductListChkAdapter);      

    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
}

public void OnClickbillbtncancel(View paramView) {
    MainActivity.textClear();
    Intent localIntent = new Intent(ProductListChkActivity.this,
            MainActivity.class);
    ProductListChkActivity.this.startActivity(localIntent);
}

}

我想将productinofchk布局显示为对话框

1 个答案:

答案 0 :(得分:0)

你需要在android中经历浮动对话框。看看这个文件:

link