मैं वर्तमान में एक टुकड़ा विकसित कर रहा हूं जिसमें एल्बम की सूचियां हैं। संरचना बहुत सरल है:टुकड़े कैसे तेजी से लोड करते हैं?
क्षैतिज स्लाइडर में LinearLayour (क्षैतिज) शामिल है। गीत सूची के साथ एक एल्बम जोड़ने के लिए मैंने एक अलग दृश्य बनाया है जिसमें कवर छवि और एक सूचीदृश्य शामिल है। सूचीदृश्य कस्टम भी है जहां आइटम 3 टेक्स्टव्यू के साथ लाइनरलेआउट हैं। फिर मैं इसे फुलाता हूं, सूची तैयार करता हूं, और क्षैतिज स्लाइडर में जोड़ता हूं।
समस्या तब होती है जब मेरे पास 2 से अधिक एल्बम सूचियां हों। एक टुकड़ा खोलने में कुछ समय लगता है।
एक और बात यह है कि जब मैं स्क्रॉल करने की कोशिश करता हूं (क्षैतिज), कभी-कभी यह एक छोटे से पल के लिए रुक जाता है, जो खराब उपयोगकर्ता अनुभव बनाता है।
जो मैं कहने की कोशिश कर रहा हूं वह यह है कि मैंने समान विचार देखा है और वे जल्दी से काम करते हैं और बिना किसी झगड़े के काम करते हैं। क्या इसे किसी भी तरह अनुकूलित करना संभव है? या यह संभव है कि टुकड़ा सीधे खुलता है और फिर सूची बाद में लोड होती है (आलसी लोड की तरह)।
ListView मद:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#ccffffff"
android:padding="10dp" >
<TextView
android:id="@+id/album_list_item_number"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:text=""
android:gravity="center|center_vertical"
android:layout_gravity="center|center_vertical"
android:textColor="#333333"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/album_list_item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:layout_weight="1"
android:gravity="left|center_vertical"
android:layout_gravity="left|center_vertical"
android:textColor="#333333"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/album_list_item_time"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:text=""
android:gravity="center|center_vertical"
android:layout_gravity="center|center_vertical"
android:textColor="#333333"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
सूची को आबाद करने और क्षैतिज स्लाइडर को देखें जोड़ना:
View albumView = inflater.inflate(R.layout.artist_album_col, container, false);
//setting cover
ImageView albumCover = (ImageView) albumView.findViewById(R.id.artistAlbumCover);
albumCover.setImageDrawable(getResources().getDrawable(R.drawable.albumcover)); //cover
ListView albumList = (ListView) albumView.findViewById(R.id.artistSongList);
// create the grid item mapping
String[] from = new String[] {"num", "title", "time"};
int[] to = new int[] { R.id.album_list_item_number, R.id.album_list_item_title, R.id.album_list_item_time};
// prepare the list of all records
List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
for(int i = 0; i < 24; i++){
HashMap<String, String> map = new HashMap<String, String>();
map.put("num", "" + i);
map.put("title", "title title title title title title title title title " + i);
map.put("time", "time " + i);
fillMaps.add(map);
}
// fill in the grid_item layout
SimpleAdapter adapter = new SimpleAdapter(mContext, fillMaps, R.layout.album_list_item, from, to);
albumList.setAdapter(adapter);
albumContainer.addView(albumView);
क्या आप यह देखने के लिए पर्याप्त कोड प्रदान कर सकते हैं कि आप अपने टुकड़े और एडेप्टर कैसे बनाते हैं ताकि SO समुदाय इसकी समीक्षा कर सके और उचित सुझाव दे सके? – petey
पता लगाने के लिए ट्रेसव्यू का उपयोग करें कि आपका समय कहां खर्च किया जा रहा है। – CommonsWare