0

我有一个带有 textview 的列表,许多数据在列表中流动,并且在 xml 中有一个 textview....问题是我想更新列表中的每个 textview 条目..我想更新 (TAG_QTY) textview列出每个值条目...

ListAdapter adapter = new SimpleAdapter(this, contactList,
            R.layout.list_item,
            new String[] { TAG_BARCODE, TAG_DIVISION, TAG_MRP,TAG_QTY}, new int[] {
                    R.id.txt, R.id.txt1, R.id.mrp,R.id.qty1 });
    setListAdapter(adapter);
    // selecting single ListView item
    ListView lv = getListView();

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //String name = ((TextView) view.findViewById(R.id.qty1)).getText().toString();
            LayoutInflater li = LayoutInflater.from(context);
            View promptsView = li.inflate(R.layout.prompts, null);
            //final View textEntryView;

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                    context);

            // set prompts.xml to alertdialog builder
            alertDialogBuilder.setView(promptsView);
            fourth = (TextView)findViewById(R.id.qty1);
            userInput = (EditText)promptsView.findViewById(R.id.editTextDialogUserInput);
            //String ed = userInput.getText().toString();
          //final int ed= Integer.parseInt(userInput.getText().toString());
            alertDialogBuilder
                    .setCancelable(false)
                    .setPositiveButton("OK",
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,int id) {
                                    String ed = userInput.getText().toString().trim();
                                    fourth.setText(ed);
                             }
                            })
                    .setNegativeButton("Cancel",
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,int id) {
                                    dialog.cancel();
                                }
                            });

            // create alert dialog
            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();

        }
    }
    );
4

1 回答 1

1

为了得到列表视图子

 lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        View c = lv.getChildAt(position);
        // c is your list view child which is clicked
        final TextView tv = (TextView) c.findViewById(R.id.qty1);
        // tv is your textview of whom vwlue you have to change.
        //changes the value of textview here and den notify data set changed and refresh the list.         
       }
     });    
于 2013-07-07T15:03:52.540 回答