Note that there are some explanatory texts on larger screens.

plurals
  1. POSet typeface for listview
    primarykey
    data
    text
    <p>i tried to set typeface for text view with this method:</p> <pre><code>public static final void setAppFont(ViewGroup mContainer, Typeface mFont) { if (mContainer == null || mFont == null) return; final int mCount = mContainer.getChildCount(); // Loop through all of the children. for (int i = 0; i &lt; mCount; ++i) { final View mChild = mContainer.getChildAt(i); if (mChild instanceof TextView) { // Set the font if it is a TextView. ((TextView) mChild).setTypeface(mFont); } else if (mChild instanceof ViewGroup) { // Recursively attempt another ViewGroup. setAppFont((ViewGroup) mChild, mFont); } } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // See assets/res/any/layout/styled_text.xml for this // view layout definition. setContentView(R.layout.read_asset); final Typeface mFont = Typeface.createFromAsset(getAssets(), "myfont.otf"); final ViewGroup mContainer = (ViewGroup) findViewById( android.R.id.content).getRootView(); MyActivity.setAppFont(mContainer, mFont); } </code></pre> <p>but now i want to set the same typeface for this listview adapter:</p> <pre><code>public class MainActivity extends Activity { // List view private ListView lv; // Listview Adapter ArrayAdapter&lt;String&gt; adapter; // Search EditText EditText inputSearch; // ArrayList for Listview ArrayList&lt;HashMap&lt;String, String&gt;&gt; productList; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Listview Data String products[] = {"item1", "item2","item3","item4","item5","item6" }; lv = (ListView) findViewById(R.id.list_view); inputSearch = (EditText) findViewById(R.id.inputSearch); // Adding items to listview adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, R.id.product_name, products); lv.setAdapter(adapter); /** * Enabling Search Filter * */ inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text MainActivity.this.adapter.getFilter().filter(cs); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } }); } } </code></pre> <p>Are there any suggestions? thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    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