2012-08-22 20 views
15

समाप्त हुआ मैं जानना चाहता हूं कि BaseAdapter.notifyDataSetChanged() खत्म करें और फिर बेटा करें। मेरे कोड:पता लगाएं जब BaseAdapter.notifyDataSetChanged()

BaseAdapter.notifyDataSetChanged(); 
mScroller.startScroll(oldX, 0, dx, 0); 

mScrollernotifyDataSetChanged() खत्म होने से पहले स्क्रॉल। notifyDataSetChanged() खत्म होने के बाद oldX पर स्क्रॉल करने के लिए मुझे mScroller चाहिए।

कृपया मेरी मदद करें, धन्यवाद।

+0

किसी ने मुझसे मदद :( – hiepnh

+10

[इस] को देखने के (http://stackoverflow.com/questions/6942582/smoothscrolltoposition-after-notifydatasetchanged-not-working-in-android) प्रश्न। संभावित डुप्लिकेट। – grine4ka

+0

https://stackoverflow.com/a/20997828/5255006 आपकी मदद करेगा –

उत्तर

0

मैं एक ही समस्या हो रही थी और मैं इस-

BaseAdapter.notifyDataSetChanged(); 
new Handler().postDelayed(new Runnable() { 
     @Override 
       public void run() { 
       mScroller.startScroll(oldX, 0, dx, 0); 
       //write scroll code here 
       } 
     },50); //scroll after 50ms 
0

मैं एक ही सटीक समस्या थी कर रही अंत, यह मेरे लिए पूरी तरह से काम किया बाहर की कोशिश करो। आप विधि को ओवरराइड कर रहे हैं DataSetChanged()। आप इसे अपने एडाप्टर क्लास में करते हैं। बस मैंने जो कोड पोस्ट किया है उसकी प्रतिलिपि बनाएँ और उस लाइन को प्रतिस्थापित करें जहां मैंने सेट किया है चयन() जिसे आपने कभी भी किया है।

@Override 
public void notifyDataSetChanged() 
{ 
    super.notifyDataSetChanged(); 

    parentGlobal.setSelection(this.getCount() - 1); //This is how we start Activity fully scrolled to bottom 
} 

इसके साथ ही कहा, मामले में आप सोच रहे हैं, "parentGlobal" ListView है कि मैं अपने गतिविधि में करने के लिए एडाप्टर सेट है। एडाप्टर के निर्माता में, मैंने ListView में पास किया और फिर इसे "वैश्विक" बना दिया। मैं क्षमा चाहता हूं कि "वैश्विक" जावा शब्द नहीं है, मैं एक सी ++ दुनिया से आया हूं।

// गतिविधि में चला जाता है:

lv_main = (ListView) findViewById(R.id.listView_conversation); 
    adapter_main = new Adapter_Conversation(ConversationActivity.this, R.layout.layout_list_conversation, 
      list_main_UI, lv_main, main_list_item_margin_px); 
    lv_main.setAdapter(adapter_main); 

// एडाप्टर में चला जाता है

public Adapter_Conversation(AppCompatActivity activity, @LayoutRes int resource, 
          ArrayList<Adapter_GetSet_Conversation> list_conversation, ListView lv_main, 
          int item_margin_px) 
संबंधित मुद्दे