Android listview不存储我从AlertDialog微调器带来的项目

Android listview不存储我从AlertDialog微调器带来的项目,android,listview,android-listview,spinner,android-alertdialog,Android,Listview,Android Listview,Spinner,Android Alertdialog,请帮帮我。我有一个带有微调器的alertDialog。我正在那里选择项目。此项发布到listView(它的工作正常)。当我放置buton时,listView项目正在删除。如何保存所有项目 这是我的代码: listView = (ListView) findViewById(R.id.listView1); // Создаём пустой массив для хранения имен котов RadioGroup radiogroup = (RadioGr

请帮帮我。我有一个带有微调器的alertDialog。我正在那里选择项目。此项发布到listView(它的工作正常)。当我放置buton时,listView项目正在删除。如何保存所有项目

这是我的代码:

    listView = (ListView) findViewById(R.id.listView1);

    // Создаём пустой массив для хранения имен котов


    RadioGroup radiogroup = (RadioGroup) findViewById(R.id.radioGroup1);
    seekbar2 = (SeekBar)findViewById(R.id.seekBar2);
    seekbar2.setOnSeekBarChangeListener(this);

    mTextValue2 = (TextView)findViewById(R.id.textView2);
    mTextValue2.setText("0");

    but1 = (Button)findViewById(R.id.button1);

    radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // TODO Auto-generated method stub
            switch (checkedId) {
            case R.id.radio1:
                vidmark = 7;
                break;
            case R.id.radio2:
                vidmark = 6;
                break;

            default:
                break;
            }
        }
    });

}

public void onMyDialogClick(View view)  
{  

    final ArrayList<String> drinks = new ArrayList<String>();

    // Создаём адаптер ArrayAdapter, чтобы привязать массив к ListView
    final ArrayAdapter<String> adapterList;
    adapterList = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, drinks);
    // Привяжем массив через адаптер к ListView
    listView.setAdapter(adapterList);

    AlertDialog.Builder Dialog = new AlertDialog.Builder(this);
     Dialog.setTitle("Добавить порцию");
     LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     View dialogView = li.inflate(R.layout.dialog, null);
     Dialog.setView(dialogView);
     final TextView txt = (TextView)dialogView.findViewById(R.id.textDialog1);
     txt.setText("Кол-во: 0г");
     SeekBar seek1 = (SeekBar) dialogView.findViewById(R.id.seekBarDialog1);
     seek1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
         if (progress % 10 == 0) {
             txt.setText("Кол-во: " + progress + "г");
         }
     }

     public void onStartTrackingTouch(SeekBar arg0) {

     }

     public void onStopTrackingTouch(SeekBar seekBar) {

     }

     });


      Dialog.setPositiveButton("Добавить",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        Toast.makeText(getApplicationContext(), selItem, Toast.LENGTH_SHORT).show();
                        drinks.add(0, selItem);
                        adapterList.notifyDataSetChanged();
                    }
                });

      Dialog.setNegativeButton("Закрыть",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                    }
                });
        Dialog.show();
        Spinner spinnercategory = (Spinner) dialogView
                .findViewById(R.id.spinnerDialog);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.alco_array, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnercategory.setAdapter(adapter);

        spinnercategory.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1,
                    int arg2, long arg3) {
                selItem = parent.getSelectedItem().toString();

            }

            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub
            }
        });

    }
listView=(listView)findViewById(R.id.listView1);
// Создаём пустой массив для хранения имен котов
放射组放射组=(放射组)findViewById(R.id.RadioGroup 1);
seekbar2=(SeekBar)findViewById(R.id.seekbar2);
seekbar2.setonseekbarchaneglistener(这个);
mTextValue2=(TextView)findViewById(R.id.textView2);
mTextValue2.setText(“0”);
但是1=(按钮)findViewById(R.id.button1);
radiogroup.setOnCheckedChangeListener(新的radiogroup.OnCheckedChangeListener(){
@凌驾
检查更改后的公共无效(RadioGroup组,int checkedId){
//TODO自动生成的方法存根
开关(检查EDID){
案例R.id.1:
维德马克=7;
打破
案例R.id.2:
维德马克=6;
打破
违约:
打破
}
}
});
}
MyDialogClick上的公共无效(视图)
{  
最终ArrayList饮料=新ArrayList();
//阵列适配器,列表视图
最终阵列适配器列表;
适配器列表=新阵列适配器(此,
android.R.layout.simple_list_item_1,饮料);
//列表视图
setAdapter(adapterList);
AlertDialog.Builder Dialog=新建AlertDialog.Builder(此);
对话框。设置标题(“бббббббббббббб107;
LayoutInflater li=(LayoutInflater)getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
视图对话框视图=li.充气(R.layout.dialog,null);
Dialog.setView(dialogView);
final TextView txt=(TextView)dialogView.findViewById(R.id.textDialog1);
txt.setText(“ББП-ББ:0Γ”);
SeekBar seek1=(SeekBar)dialogView.findViewById(R.id.seekbartialog1);
seek1.setonseekbarchaneglistener(新SeekBar.onseekbarchaneglistener(){
public void onProgressChanged(SeekBar-SeekBar、int-progress、boolean-fromUser){
如果(进度%10==0){
txt.setText(“ББП-СС:“+进度+”Γ”);
}
}
开始跟踪触摸时的公共无效(请参见kbar arg0){
}
TopTrackingTouch(SeekBar SeekBar)上的公共无效{
}
});
对话框.setPositiveButton(“бббббббб”,
新建DialogInterface.OnClickListener(){
public void onClick(对话框接口对话框,int whichButton){
Toast.makeText(getApplicationContext(),selItem,Toast.LENGTH_SHORT).show();
饮料。添加(0,选择项);
adapterList.notifyDataSetChanged();
}
});
对话框。设置消极按钮(“аацца”,
新建DialogInterface.OnClickListener(){
public void onClick(对话框接口对话框,int whichButton){
}
});
Dialog.show();
微调器微调器类别=(微调器)对话框视图
.findviewbyd(R.id.spinnerDialog);
ArrayAdapter=ArrayAdapter.createFromResource(
这个,R.array.alco_数组,android.R.layout.simple_微调器_项);
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
喷丝头类别。设置适配器(适配器);
spinnercategory.setOnItemSelectedListener(新的OnItemSelectedListener(){
已选择公共视图(AdapterView父视图,视图arg1,
整数arg2,长arg3){
selItem=parent.getSelectedItem().toString();
}
未选择公共无效(AdapterView arg0){
//TODO自动生成的方法存根
}
});
}

您可以使用
适配器列表。添加(sellItem)


如果您想将项目插入列表的顶部,很遗憾,您必须扩展
ArrayAdapter
,并在那里存储您自己的列表。

谢谢,但这不是我需要的。每次,我都会按下按钮并创建新的arrayAdapter,但我不需要新的适配器)