1

我有一个 ListView,其中每个项目都有一个 edittext,当我在 editTexts 中写一些东西并滚动 listview 时,我输入的数据将消失。我已经阅读了这个主题,但真的不知道我应该如何处理我的编码形式!任何人都可以帮助我吗?

爪哇代码:

public class ListView extends ListActivity {
    /** Called when the activity is first created. */
    private TextView selection;
    private static final String[] items = {"مخصوص", "مخلوط", "یونانی", "قارچ و گوشت", "پپرونی", "مرغ و قارچ", "سبزیجات", "دریایی"};
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view);

        setListAdapter(new IconicAdapter());
        selection = (TextView)findViewById(R.id.selection);

    }
    private String getModel(int position){
        return(((IconicAdapter)getListAdapter()).getItem(position));
    }

    public void onListItemClick(ListView parent, View v, int position, long id){
        selection.setText(items[position]);
    }



 //=====================
 //New Class Starts Here
 //=====================
    class IconicAdapter extends ArrayAdapter<String> {

        public IconicAdapter() {
            super(ListView.this, R.layout.row, items);
        }

        public View getView(int position, View convertView, ViewGroup parent){
            LayoutInflater inflater = getLayoutInflater();
            final View row = inflater.inflate(R.layout.row, parent, false);



            TextView label = (TextView)row.findViewById(R.id.label);
            label.setText(items[position]);

            ImageView icon = (ImageView)row.findViewById(R.id.pic);


            if(getModel(position).contentEquals("مخصوص")){
                icon.setImageResource(R.drawable.download);
            }
            else if (getModel(position).contains("دریایی")){
                icon.setImageResource(R.drawable.drink);
            }
            else if (getModel(position).contains("سبزیجات")){
                icon.setImageResource(R.drawable.french);
            }
            else if (getModel(position).contains("مرغ و قارچ")){
                icon.setImageResource(R.drawable.frenchfrise);
            }
            else if (getModel(position).contains("پپرونی")){
                icon.setImageResource(R.drawable.sandwich);
            }
            else if (getModel(position).contains("قارچ و گوشت")){
                icon.setImageResource(R.drawable.ic_launcher);
            }
            else if (getModel(position).contains("یونانی")){
                icon.setImageResource(R.drawable.sandwich);
            }
            else if (getModel(position).contains("مخلوط")){
                icon.setImageResource(R.drawable.sandwich);
            }
            else if (getModel(position).contains("مخصوص")){
            icon.setImageResource(R.drawable.sandwich);
            }


            return(row);
        }

    }
}
4

0 回答 0