Android 如何将自定义字体应用于我的ListView项目?
这是我的主要java代码:Android 如何将自定义字体应用于我的ListView项目?,android,android-layout,android-listview,android-fonts,Android,Android Layout,Android Listview,Android Fonts,这是我的主要java代码: public class MainActivity extends ActionBarActivity { String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu"}; @Override protected void onCreate(Bundle savedInstanceState) { super.o
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);
}
}
公共类MainActivity扩展了ActionBarActivity{
String[]mobileArray={“Android”、“IPhone”、“WindowsMobile”、“Blackberry”、“WebOS”、“Ubuntu”};
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter=新的ArrayAdapter(this,R.layout.activity\u listview,mobileArray);
ListView ListView=(ListView)findViewById(R.id.mobile\u列表);
setAdapter(适配器);
}
}
我的活动\u main.xml文件:
<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>
<?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>
我的活动\u listview.xml文件:
<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>
<?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>
Google坏了还是怎么了?Listview项目只是视图。只要搜索改变文本视图的字体,你就会发现几十篇文章。。。