-2

Am getting value here for Checkbox, and textview properly. But, I could not get the EditText Values. am getting empty only.

my sample code:

View view = null ;
for(int i = 0; i < list.getCount(); i++ ) {
    view = list.getAdapter().getView(i, null, null) ;

    TextView textViewNickName = (TextView) view.findViewById(R.id.textview);

    String textviewValue = textViewNickName.getText().toString().trim() ;

    Log.v("ppi", "textViewNickName::"+textviewValue);

    EditText edittext = (EditText) view.findViewById(R.id.edittext_amount)    ;

    String edittextValue = edittext.getText().toString().trim() ;

    Log.v("ppi", "Amount edittextValue::"+edittextValue);

    CheckBox checkBoxOne = (CheckBox) view.findViewById(R.id.checkBox1) ;

    Log.v("ppi", "checkBoxOne::"+checkBoxOne.isChecked());

}

I referred this link also : Iterate through ListView and get EditText-Field values

Thanks Advance

Community
  • 1
  • 1
harikrishnan
  • 1,985
  • 4
  • 32
  • 63

1 Answers1

0

You have mistake to get value from EditText, any event time you can get value initialization time you can't get text from EditText

  EditText edittext = (EditText) view.findViewById(R.id.edittext_amount) ;
  String edittextValue = edittext.getText().toString().trim() ;
  Log.v("ppi", "Amount edittextValue::"+edittextValue);

see above code that in your mistake if you have no enter any string in EditText then how can you retrieve initialization time.

you have to make change in you code as like blow.

   EditText edittext = (EditText) view.findViewById(R.id.edittext_amount) ;

   btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String edittextValue = edittext.getText().toString().trim() ;
           Log.v("ppi", "Amount edittextValue::"+edittextValue);
        }
    });
Ravi Vaghela
  • 3,420
  • 2
  • 23
  • 51
  • thank you.. we are entering dynamic value to edittext while viewing listview. after that only, we are trying to get value from submit onclicklistener – harikrishnan Apr 27 '16 at 07:57