开发者

About check box

protected CharSequence[] _options = { "English ", "Thai", "German", "Italy", "Spain", "All languages" };
protected boolean[] _selections =  new boolean[ _options.length ];
@Override
protected Dialog onCreateDialog( int id ) 
{
    return 
    new AlertDialog.Builder( this )
        .setTitle( "Choose Language" )
        .setMultiChoiceItems( _options, _selections, new DialogSelectionClickHandler() )
        .setPositiveButton( "OK", new Dialog开发者_如何转开发ButtonClickHandler() )
        .create();
}

public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
{
    @Override
    public void onClick( DialogInterface dialog, int clicked, boolean selected )
    {
        Log.i( "ME", _options[ clicked ] + " selected: " + selected );
    }
}

public class DialogButtonClickHandler implements DialogInterface.OnClickListener
{
    @Override
    public void onClick( DialogInterface dialog, int clicked )
    {
        switch( clicked )
        {
            case DialogInterface.BUTTON_POSITIVE:

                printSelectedLanguage();
                break;
        }
    }
}
protected void printSelectedLanguage(){
    for( int i = 0; i < _options.length; i++ ){
        Log.i( "ME", _options[ i ] + " selected: " + _selections[i] );
    }
}

How can I check that which checkbox is checked


final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
         if (checkBox.isChecked()) {
            // action
         }

Using standart checkbox method. By the way i don't see any in the code


Try this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜