Note that there are some explanatory texts on larger screens.

plurals
  1. POSet font for ListView, Android
    primarykey
    data
    text
    <p>I spent all day searching for an answer, found a lot, but all of them are not what I need. So, I have a pretty simple menu with ListView and a file for items with TextView. I want to set Segoe-Print font for items in my menu, I know, that I need adapter, but I can't do it. Help!!!</p> <p>menu.xml: </p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;LinearLayout android:id="@+id/menu_top" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/menu_top"&gt; &lt;/LinearLayout&gt; &lt;ListView android:id="@+id/ListView_Menu" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/fon_android" android:divider="@drawable/menu_line" android:textStyle="bold" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>menu_item.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/menu_prop" android:layout_width="fill_parent" android:textSize="19px" android:text="test string" android:layout_gravity="left" android:layout_height="wrap_content" android:shadowRadius="5" android:textColor="@color/menu_color" android:shadowDy="3" android:shadowDx="3" /&gt; </code></pre> <p>A part of Main_Menu.java:</p> <pre><code>public class Main_menu extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.menu); ListView menuList = (ListView) findViewById(R.id.ListView_Menu); String[] items = { getResources().getString(R.string.system), getResources().getString(R.string.convert), getResources().getString(R.string.forks), getResources().getString(R.string.margin)}; ArrayAdapter&lt;String&gt; adapt = new ArrayAdapter&lt;String&gt;(this,R.layout.menu_item, items); menuList.setAdapter(adapt); } </code></pre> <p>CustomAdapter.java:</p> <pre><code>public class CustomAdapter extends ArrayAdapter&lt;String&gt; { public CustomAdapter(Context context, int resource, String[] objects) { super(context, resource, objects); // TODO Auto-generated constructor stub } public View getView (int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(R.id.menu_prop); Typeface font = Typeface.createFromAsset(getAssets(), "segoe_print.ttf"); textView.setTypeface(font); return textView; } private AssetManager getAssets() { // TODO Auto-generated method stub return null; } } </code></pre> <p>The font doesn't change...</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