Note that there are some explanatory texts on larger screens.

plurals
  1. POslow listview when set custom font
    text
    copied!<p>I have some data in an xml file put it in /res/values/mydata.xml. I want to show data in a listview with a custom font. Everything is great in emulator but in real device (using samsung galaxy tab 10.1 2 with android 4.0.3) is too slow when scroll listview. Actually it works great with default font but the problem appears when set the custom font.</p> <p>This is my java code:</p> <pre><code>public class ShowFoodCalorie extends ListActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // reading data from xml file setListAdapter(new MyAdapter(this, android.R.layout.simple_list_item_1, R.id.textView1, getResources().getStringArray(R.array.food_cal))); } private class MyAdapter extends ArrayAdapter&lt;String&gt; { public MyAdapter(Context context, int resource, int textViewResourceId, String[] string) { super(context, resource, textViewResourceId, string); } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.show_all, parent, false); String[] item = getResources().getStringArray(R.array.food_cal); TextView tv = (TextView) row.findViewById(R.id.textView1); try { Typeface font = Typeface.createFromAsset(getAssets(),"myFont.ttf"); tv.setTypeface(font); } catch (Exception e) { Log.d("Alireza", e.getMessage().toString()); } tv.setText(item[position]); return row; } } </code></pre> <p>what is this problem? it's about my device? Any solution can help me. Thanks</p>
 

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