Example usage for android.widget ArrayAdapter ArrayAdapter

List of usage examples for android.widget ArrayAdapter ArrayAdapter

Introduction

In this page you can find the example usage for android.widget ArrayAdapter ArrayAdapter.

Prototype

public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects) 

Source Link

Document

Constructor

Usage

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptImageName(final Activity activity, String hd) {
    final String hd_string = hd;
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Image Name");

    RelativeLayout mLayout = new RelativeLayout(this);
    mLayout.setId(12222);/*  w  w  w  .j  a  v  a2  s  . com*/

    EditText imageNameView = new EditText(activity);
    imageNameView.setEnabled(true);
    imageNameView.setVisibility(View.VISIBLE);
    imageNameView.setId(201012010);
    imageNameView.setSingleLine();
    RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    mLayout.addView(imageNameView, searchViewParams);

    final Spinner size = new Spinner(this);
    RelativeLayout.LayoutParams setPlusParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    size.setId(201012044);

    String[] arraySpinner = new String[7];
    for (int i = 0; i < arraySpinner.length; i++) {

        if (i < 5) {
            arraySpinner[i] = (i + 1) + " GB";
        }

    }
    arraySpinner[5] = "10 GB";
    arraySpinner[6] = "20 GB";

    ArrayAdapter sizeAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    sizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    size.setAdapter(sizeAdapter);
    setPlusParams.addRule(RelativeLayout.BELOW, imageNameView.getId());
    mLayout.addView(size, setPlusParams);

    // TODO: Not working for now
    // final TextView preallocText = new TextView(this);
    // preallocText.setText("Preallocate? ");
    // preallocText.setTextSize(15);
    // RelativeLayout.LayoutParams preallocTParams = new
    // RelativeLayout.LayoutParams(
    // RelativeLayout.LayoutParams.WRAP_CONTENT,
    // RelativeLayout.LayoutParams.WRAP_CONTENT);
    // preallocTParams.addRule(RelativeLayout.BELOW, size.getId());
    // mLayout.addView(preallocText, preallocTParams);
    // preallocText.setId(64512044);
    //
    // final CheckBox prealloc = new CheckBox(this);
    // RelativeLayout.LayoutParams preallocParams = new
    // RelativeLayout.LayoutParams(
    // RelativeLayout.LayoutParams.WRAP_CONTENT,
    // RelativeLayout.LayoutParams.WRAP_CONTENT);
    // preallocParams.addRule(RelativeLayout.BELOW, size.getId());
    // preallocParams.addRule(RelativeLayout.RIGHT_OF,
    // preallocText.getId());
    // preallocParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,
    // preallocText.getId());
    // mLayout.addView(prealloc, preallocParams);
    // prealloc.setId(64512344);

    alertDialog.setView(mLayout);

    final Handler handler = this.handler;

    // alertDialog.setMessage(body);
    alertDialog.setButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            int sizeSel = size.getSelectedItemPosition();
            String templateImage = "hd1g.qcow2";
            if (sizeSel < 5) {
                templateImage = "hd" + (sizeSel + 1) + "g.qcow2";
            } else if (sizeSel == 5) {
                templateImage = "hd10g.qcow2";
            } else if (sizeSel == 6) {
                templateImage = "hd20g.qcow2";
            }

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(201012010);
            progDialog = ProgressDialog.show(activity, "Please Wait", "Creating HD Image...", true);
            // CreateImage createImg = new
            // CreateImage(a.getText().toString(),
            // hd_string, sizeInt, prealloc.isChecked());
            //            CreateImage createImg = new CreateImage(a.getText().toString(),
            //                  hd_string, sizeInt, false);
            //            createImg.execute();

            String image = a.getText().toString();
            if (!image.endsWith(".qcow2")) {
                image += ".qcow2";
            }
            createImg(templateImage, image, hd_string);

        }
    });
    alertDialog.show();

}

From source file:com.example.sensingapp.SensingApp.java

public void show_screen4() {

    setContentView(R.layout.screen_4_start);

    m_spnScreen4_SelectSensorDataLabel = (Spinner) findViewById(R.id.Screen4_spnSelectSensorDataLabel);

    m_adpSensorDataLabel = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            m_lstSensorDataLabel);/*from   w ww . j  av  a  2s .com*/
    m_adpSensorDataLabel.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    m_spnScreen4_SelectSensorDataLabel.setAdapter(m_adpSensorDataLabel);

    m_chkNoLabel = (CheckBox) findViewById(R.id.chkNoLabel);

    m_btnScreen4_Start = (Button) findViewById(R.id.btScreen4_Start);
    m_btnScreen4_Start.setOnClickListener(m_btnStartRecordListener);

    m_btnScreen4_Back = (Button) findViewById(R.id.btScreen4_Back);
    m_btnScreen4_Back.setOnClickListener(m_btnScreen4_Back_Listener);

    m_chkNoLabel.setChecked(m_blnNoLabel);
    m_chkNoLabel.setOnCheckedChangeListener(m_chkNoLabel_Listener);
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateRAM() {
    this.userPressedRAM = false;

    String[] arraySpinner = new String[128];

    for (int i = 0; i < arraySpinner.length; i++) {
        arraySpinner[i] = (i + 1) * 8 + "";
    }//from w  w w .ja  va2  s  . c om
    ;

    ramAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    ramAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mRamSize.setAdapter(ramAdapter);
    this.userPressedRAM = false;
    this.mRamSize.invalidate();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateCPUNum() {
    this.userPressedCPUNum = false;

    String[] arraySpinner = new String[4];

    for (int i = 0; i < arraySpinner.length; i++) {
        arraySpinner[i] = (i + 1) + "";
    }//  w  ww.  j a v  a 2 s.c  o m
    ;

    cpuNumAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    cpuNumAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mCPUNum.setAdapter(cpuNumAdapter);
    this.userPressedCPUNum = false;
    this.mCPUNum.invalidate();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateBootDevices() {

    String[] arraySpinner = { "Default", "CD Rom", "Floppy", "Hard Disk" };

    bootDevAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    bootDevAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mBootDevices.setAdapter(bootDevAdapter);
    this.mBootDevices.invalidate();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateNet() {
    String[] arraySpinner = { "None", "User", "TAP" };
    netAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    netAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mNetConfig.setAdapter(netAdapter);
    this.mNetConfig.invalidate();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateVGA() {

    String[] arraySpinner = { "std", "cirrus", "vmware", "qxl", "xenfb", "none" };

    vgaAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    vgaAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mVGAConfig.setAdapter(vgaAdapter);
    this.mVGAConfig.invalidate();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateSoundcardConfig() {

    String[] arraySpinner = { "None", "sb16", "ac97", "es1370", "hda", "all" };

    sndAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    sndAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mSoundCardConfig.setAdapter(sndAdapter);
    this.mSoundCardConfig.invalidate();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void populateHDCacheConfig() {

    String[] arraySpinner = { "default", "none", "writeback", "writethrough" };

    hdCacheAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    hdCacheAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mHDCacheConfig.setAdapter(hdCacheAdapter);
    this.mHDCacheConfig.invalidate();
}