Note that there are some explanatory texts on larger screens.

plurals
  1. POSamsung s3 bug with listview
    primarykey
    data
    text
    <p>I have worked on a custom list view which is a pull down to refresh listview but it is showing a strange error , whenever i try to run it on my galaxy s3 , it starts saying </p> <blockquote> <p>I/Choreographer(698): Skipped 340 frames! The application may be doing too much work on its main thread.</p> </blockquote> <p>and the scrolling of the listview is painfully slow. Attached is video of testing on s3 and an htc device and it works flawlessly on HTC. Any pointers that why is this happening?</p> <p>HTC: <a href="http://www.youtube.com/watch?v=9o1UXv_-Uco" rel="nofollow">http://www.youtube.com/watch?v=9o1UXv_-Uco</a> S3: <a href="http://www.youtube.com/watch?v=YjjC07M70Gk" rel="nofollow">http://www.youtube.com/watch?v=YjjC07M70Gk</a></p> <p><strong>edit:code added</strong></p> <pre><code>public class MainActivity extends ListActivity implements OnScrollListener { private LinkedList&lt;String&gt; mListItems; TmbResultListViewAdapter adapter; Button editButton; public static boolean refreshOnDrag = true; private boolean isloading = false; private MyTask task; PullToRefreshListView lv; private ProgressBar footer; private TextView statusBar; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRefreshOnPull(true); setContentView(R.layout.activity_main); statusBar = (TextView) findViewById(R.id.statusbar); editButton = (Button) findViewById(R.id.editButton); lv = (PullToRefreshListView) getListView(); lv.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { // Do work to refresh the list here. if (refreshOnDrag) { new GetDataTask().execute(); } } }); lv.setOnScrollListener(this); lv.setScrollingCacheEnabled(false); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); footer = (ProgressBar) inflater.inflate(R.layout.footer, null); mListItems = new LinkedList&lt;String&gt;(); mListItems.addAll(Arrays.asList(mStrings)); // ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, // android.R.layout.simple_list_item_1, mListItems); adapter = new TmbResultListViewAdapter(this); setListAdapter(adapter); } public void edit(View v) { if (!adapter.showEditControlls) { adapter.showEditControlls = true; adapter.notifyDataSetChanged(); editButton.setText("Done"); } else { adapter.showEditControlls = false; adapter.notifyDataSetChanged(); editButton.setText("Edit"); } } public void setRefreshOnPull(boolean val) { this.refreshOnDrag = val; } private class GetDataTask extends AsyncTask&lt;Void, Void, String[]&gt; { @Override protected String[] doInBackground(Void... params) { // Simulates a background job. try { Thread.sleep(1000); } catch (InterruptedException e) { ; } adapter.resetItems(); return mStrings; } @Override protected void onPostExecute(String[] result) { mListItems.addFirst("Added after refresh..."); // Call onRefreshComplete when the list has been refreshed. ((PullToRefreshListView) getListView()).onRefreshComplete(); super.onPostExecute(result); } } private String[] mStrings = { "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", "Allgauer Emmentaler" }; @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int loadedItems = firstVisibleItem + visibleItemCount; int offSet = (((int) ((firstVisibleItem - 1) / adapter.getItemPerPage())) * adapter .getItemPerPage()) + 1; statusBar.setText(offSet + " of " + (offSet + adapter.getItemPerPage() - 1)); if ((loadedItems == totalItemCount) &amp;&amp; !isloading) { if (task == null || (task.getStatus() == AsyncTask.Status.FINISHED)) { task = new MyTask(); task.execute(); } } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // TODO Auto-generated method stub } class MyTask extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); ((PullToRefreshListView) getListView()).addFooterView(footer); // adapter.notifyDataSetChanged(); } @Override protected Void doInBackground(Void... params) { isloading = true; adapter.loadMoreData(); // ProgressBar pb = new ProgressBar(getApplicationContext(), null, // android.R.attr.progressBarStyleHorizontal); // LinearLayout linLayout = (LinearLayout) // findViewById(R.id.linearLayout); // linLayout.addView(pb); Log.d("*****", "Loading..."); return null; } @Override protected void onPostExecute(Void result) { // adapter.notifyDataSetChanged(); isloading = false; adapter.notifyDataSetChanged(); ((PullToRefreshListView) getListView()).removeFooterView(footer); } } @Override public void onBackPressed() { finish(); } } </code></pre> <p><strong>adapter code added</strong> I have seen that when ever i try to scroll the skipping frames get even worse. so may be i am doing a lot of work on the getview method </p> <pre><code> public View getView(final int position, View convertView, ViewGroup parent) { //View convertView = convertView; // TmbJSON eventDetail; if (convertView == null) { convertView = inflater.inflate(R.layout.tmb_result_listitem, null); mViewHolder = new viewHolder(); mViewHolder.resultTitle = (TextView) convertView .findViewById(R.id.resultTitle); mViewHolder.resultPeriod = (TextView) convertView .findViewById(R.id.resultPeriod); mViewHolder.resultVenue = (TextView) convertView .findViewById(R.id.resultVenue); mViewHolder.resultDescription = (TextView) convertView .findViewById(R.id.resultDescription); mViewHolder.resultIcon = (ImageView) convertView .findViewById(R.id.resultIcon); mViewHolder.checkUnCheckIcon = (ImageView) convertView .findViewById(R.id.checkuncheckicon); mViewHolder.layout = (LinearLayout) convertView.findViewById(R.id.linearLayout); mViewHolder.headerTextView = (TextView) convertView.findViewById(R.id.itemheader); convertView.setTag(mViewHolder); } else { mViewHolder = (viewHolder) convertView.getTag(); } try { mViewHolder.checkUnCheckIcon.setVisibility(showEditControlls ? ImageView.VISIBLE : ImageView.GONE); mViewHolder.checkUnCheckIcon.setImageResource(mCheckedState.get(position) ? R.drawable.starschecked : R.drawable.starsunchecked); mViewHolder.checkUnCheckIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mCheckedState.get(position)) { mViewHolder.checkUnCheckIcon .setImageResource(R.drawable.starsunchecked); mCheckedState.set(position, false); } else if (!mCheckedState.get(position)) { mViewHolder.checkUnCheckIcon .setImageResource(R.drawable.starschecked); mCheckedState.set(position, true); } theAdapter.notifyDataSetChanged(); Toast.makeText(activity.getApplicationContext(), position+"th Event un/checked", Toast.LENGTH_LONG).show(); } }); String name = masterList.get(position).name;// eventDetail.smartStringWithPath(TmbJSON.arrayListObjectWithStrings("name")); String detail = masterList.get(position).detail;// eventDetail.smartStringWithPath(TmbJSON.arrayListObjectWithStrings("detail")); String venue = masterList.get(position).venue;// ((JSONObject)eventDetail.object).getJSONArray("prs").getJSONObject(0).getJSONObject("loc").getString("name"); String period = masterList.get(position).period;// ((JSONObject)eventDetail.object).getJSONArray("prs").getJSONObject(0).getString("ts_z"); mViewHolder.resultTitle.setText(name); mViewHolder.resultPeriod.setText(period); mViewHolder.resultVenue.setText(venue); mViewHolder.resultDescription.setText(detail); if((position) % (itemPerPage) == 0 &amp;&amp; position!=0) { mViewHolder.headerTextView.setText((position+1)+" of "+(int)(position+20)); mViewHolder.headerTextView.setVisibility(TextView.VISIBLE); } else { mViewHolder.headerTextView.setVisibility(TextView.GONE); } int forthPos = getCount() - itemPerPage + 4; int tenthPos = getCount() - itemPerPage + 10; int sixteenthPos = getCount() - itemPerPage + 16; } catch (Exception e) { e.printStackTrace(); } return convertView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload