Nullpointerexception when using listview and Arrayadapter -
hi trying populate calendar events dailog listview, while setting adapter listview getting nullpointerexception . below code
final dialog dialog = new dialog(getactivity()); dialog.setcontentview(r.layout.list_view); dialog.settitle("events"); arrayadapter<string> ad = new arrayadapter<string>(getactivity(),r.layout.list_view,r.id.text,desc);//desc string array mylist.setadapter(ad);
below layout xml file
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:id="@+id/text" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:text="" android:textappearance="?android:attr/textappearancemedium" android:textcolor="#ffffff" /> <listview android:id="@+id/mylist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:divider="#b5b5b5" android:dividerheight="1dp" /> </linearlayout>
not sure doing wrong. appreciated.
try
dialog = new dialog(your_activity.this);
also declare globally..
Comments
Post a Comment