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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -