-4

This my main java code:

public class MainActivity extends ActionBarActivity {
    String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview, mobileArray);
        ListView listView = (ListView) findViewById(R.id.mobile_list);
        listView.setAdapter(adapter);
    }
}

My activity_main.xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#ffff"
    tools:context=".ListActivity" >

    <ListView
        android:id="@+id/mobile_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

my activity_listview.xml file:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:textSize="16dip"
    android:textStyle="bold"
    android:textColor="#0060FF">
</TextView>
Lamorak
  • 10,957
  • 9
  • 43
  • 57

1 Answers1

0
 1.First make Custom ArrayAdapter
 2.In custom ArrayAdaper override getView()
 3.inflate TextView Layout in it.
 4. Assign Your Custom Font which is in Your asset Folder
    Typeface font1=Typeface.createFromAsset(getAssets(), "/fonts/UNDERCOV.ttf");

    button_1=(Button)findViewById(R.id.button1);
    button_1.setTypeface(font1);