Notify rebuilds the list. If there is any state that may have changed since the getView was called, it's up to your code to restore it.
Change your data items from strings to a richer data structure, and use them to save and restore visibility. Also, try scrolling your list view up and down, before making those fixes. You may see the visibility change back to invisible, caused by the same bug. -- Kostya Vasilyev 03.07.2011 21:39 пользователь "NikolaMKD" <[email protected]> написал: > Does calling notifyOnDataSetChanged() will restore previous settings > for each of the items, that previously had their child views > visibility set to View.VISIBLE (supposing item is clicked before) and > then set the visibility to View.VISIBLE on the item that is currently > clicked? > > See the code below: > ------------------------This is the onItemClickListener of the > listview-------------------------------------------------------- > listView.setOnItemClickListener(new OnItemClickListener(){ > > @Override > public void onItemClick(AdapterView<?> parent, View viewItem, int > position, long arg3) { > > > > click=true; > cur.notifyDataSetChanged(); > > > viewItem=parent.getChildAt(position); > > ((Button)viewItem.findViewById(R.id.gotherefav)).setVisibility(View.VISIBLE); > > ((Button)viewItem.findViewById(R.id.removefav)).setVisibility(View.VISIBLE); > > TextView text = (TextView)viewItem.findViewById(R.id.item); > ime = text.getText(); > cur.notifyDataSetInvalidated(); > }}); > -------------------------------------This is the > getView()---------------------------------------------------------------------------- > > public View getView(int position, View convertView, ViewGroup parent) > { > > if (convertView == null) { > LayoutInflater vi = > (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); > convertView = vi.inflate(R.layout.temp2, null); > } > > String t = items.get(position); > if (t != null) { > > TextView itemText = (TextView) > convertView.findViewById(R.id.item); > > itemText.setText(t); > itemText.invalidate(); > itemText.setTextSize(20.0f); > > } > > ((Button)convertView.findViewById(R.id.gotherefav)).setVisibility(View.INVISIBLE); > > ((Button)convertView.findViewById(R.id.removefav)).setVisibility(View.INVISIBLE); > > > return convertView; > > } > } > ------------------------------------------------------------------------------------ > > Do i call prematurely notifyDatasetchanged() in > listviewonclicklistener or dataSetInvalidated? Why it does not show > the buttons(child views) when the item is clicked? Please, guide me, > what i'm doing wrong? > > -- > 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 -- 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

