2014-02-11 36 views
-1

我想在選擇單選按鈕後用checklistbox實現產品列表。 我想將chekclistbox顯示爲對話框。我的產品列表數據來自sqllite。 需要實現適配器類來顯示checklistbox的數據,或者我可以直接在alertDialog中實現checklistbox數據。請爲我清楚。混淆android檢查列表框

在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佈局對話框

+0

您應該使用自定義佈局文件,並在您的AlertDialog膨脹。 – Piyush

+0

我不明白你在問什麼。請結構你的文章,格式化一下,並顯示你到目前爲止已經做了什麼 – avalancha

回答

0

你需要通過在Android的浮動對話框。看看這個文檔:

link

+0

這是**對話框**,而不是*對話框* :) –

+1

@Paresh Mayani感謝您的更正:) – Shahzeb