Item views don't exist until created by the getView method of your list view adapter. Move the code that sets attributes of views in the list item layout into there. Also call findViewById on the list item view, not on the main layout or the main view - this will make sure you get the text view in that particular item's layout, of which there are many (one for each list item).
-- Kostya Vasilyev -- http://kmansoft.wordpress.com 23.09.2010 23:08 пользователь "intbt" <[email protected]> написал: Perhaps you guys can also assist me with my custom listview problem. The listview is part of a relativelayout that I am building on a page. I want to use a custom font, when I try to attach the font to the textview (called out by the listview) the program crashes apparently because it can't find the textview inside the listview. How can I use this special font? setListAdapter(new ArrayAdapter<String>(this, R.layout.selection, R.id.type, scs)); View v = this.getLayoutInflater().inflate(R.layout.sclist, null); RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); params2.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); v.setLayoutParams(params2); Type =(TextView) v.findViewById(R.id.type); Type.setTypeface(font1);//This causes a crash in the program!! Can't find the textview. sclist.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#00000000" android:cacheColorHint="#00000000" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="horizontal" > <ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="10px" android:layout_marginTop="28px" android:textColor="@color/black" /> </LinearLayout> selection.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/type" android:layout_width="260px" android:layout_height="wrap_content" android:textSize="22px" android:textColor="@color/black" /> </LinearLayout> Thanks, intbt On Sep 23, 9:28 am, dashman <[email protected]> wrote: > worked like a charm. > > thank you. -- ... -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

