I believe getCount() is called as part of the adapter figuring out how it
is going to be displayed.
Perhaps clicking on editText is causing a softkeyboard to appear? This
would change the dimensions of the screen and cause your adapter to re
calculate.
You need to make sure the getCount() call always returns something valid.
On Sunday, April 15, 2012 5:27:48 PM UTC+1, Narendra Singh Rathore wrote:
>
> Hi all,
> I want to populate the listview (custom listview).
>
> I am doing that using -
> a) EditText, in which I type a word.
> b) Button, onClick of which sets the adapter to the list.
> c) SQLiteDatabase, for firing query in order to populate the list.
> *Note: *The query uses the text from EditText.
> d) Custom ListView, which is to be populated.
>
> Everything is fine here, except when my EditText goes empty, as in my
> getCount() method of ArrayAdapter, I am putting the count value, which is
> being generated by the query, that uses the text of EditText.
>
> Well, I am not getting why the getCount() method is being called, without
> even clicking the button.
>
> Here is my button Click
>
> button onclick
> {
> String s=mEditText.getText().toString();
> if(!s.equals("")
> {
> mListView.setAdapter(new
> TextAdapter(getApplicationContext,R.layout.list_item));
> // TextAdapter is the class extending ArrayAdapter
> int number=Integer.parseInt(s);
> mCursor=dataHelper.myMethod(number);
> count=mCursor.getCount();
> mCursor.close();
> }
>
>
> }
>
> Here is the getCount() method of Adapter class.
>
>
> class TextAdapter extends ArrayAdapter<String>
> {
> ......
> .......
> *@Override*
> *public int getCount()*
> *{*
> *return count;*
> *}*
> ..........
> ..........
> }
>
> which as per my requirement should be called when I click the button, not
> when I change something in my EditText.
>
> After the appearance of my list, when I try to change the editText value
> by removing the old one, an exception is thrown.
>
> NumberFormatException: Unable to parse ' ' as number.
>
> What should I do in order to solve my problem?
>
>
On Sunday, April 15, 2012 5:27:48 PM UTC+1, Narendra Singh Rathore wrote:
>
> Hi all,
> I want to populate the listview (custom listview).
>
> I am doing that using -
> a) EditText, in which I type a word.
> b) Button, onClick of which sets the adapter to the list.
> c) SQLiteDatabase, for firing query in order to populate the list.
> *Note: *The query uses the text from EditText.
> d) Custom ListView, which is to be populated.
>
> Everything is fine here, except when my EditText goes empty, as in my
> getCount() method of ArrayAdapter, I am putting the count value, which is
> being generated by the query, that uses the text of EditText.
>
> Well, I am not getting why the getCount() method is being called, without
> even clicking the button.
>
> Here is my button Click
>
> button onclick
> {
> String s=mEditText.getText().toString();
> if(!s.equals("")
> {
> mListView.setAdapter(new
> TextAdapter(getApplicationContext,R.layout.list_item));
> // TextAdapter is the class extending ArrayAdapter
> int number=Integer.parseInt(s);
> mCursor=dataHelper.myMethod(number);
> count=mCursor.getCount();
> mCursor.close();
> }
>
>
> }
>
> Here is the getCount() method of Adapter class.
>
>
> class TextAdapter extends ArrayAdapter<String>
> {
> ......
> .......
> *@Override*
> *public int getCount()*
> *{*
> *return count;*
> *}*
> ..........
> ..........
> }
>
> which as per my requirement should be called when I click the button, not
> when I change something in my EditText.
>
> After the appearance of my list, when I try to change the editText value
> by removing the old one, an exception is thrown.
>
> NumberFormatException: Unable to parse ' ' as number.
>
> What should I do in order to solve my problem?
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en