MrSyntax
MrSyntax

Reputation: 27

Want to update the list in every entry view?

i'am having a list with textview, many data's are flowing in list and having one textview in xml....problem is i want to update the every textview entry in the list..i want to update the (TAG_QTY) textview in list when every value entry...

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();

        }
    }
    );

Upvotes: 0

Views: 75

Answers (1)

Rachit Tyagi
Rachit Tyagi

Reputation: 678

In order to get the list view child

 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.         
       }
     });    

Upvotes: 1

Related Questions