Seth De
Seth De

Reputation: 37

expandable listview inside dialog gets error

i want to perform an expandable listview inside dialog.But i get error in the line where i set the adapter (l.setAdapter(expAdapter) acording to logcat.

protected void onCreate(Bundle savedInstanceState)
{ 

super.onCreate(savedInstanceState);

    Dialog dialog = new Dialog(getBaseContext());
        dialog.setContentView(R.layout.menu);
        int id= getIntent().getExtras().getInt("id");   
     dbAdapter = new DBAdapter(this);
     dbAdapter=dbAdapter.open(); 

      int length = dbAdapter.getDetailsOf(proion_id).size();
      Toast.makeText(getApplicationContext(),  length, Toast.LENGTH_LONG).show();


 loadData();
    ExpandableListView l = (ExpandableListView) findViewById(R.id.item_comments_explist);
    myExpandableAdapter expAdapter = new myExpandableAdapter(this,  dbAdapter.getDetailsOf(id), childs);
    l.setAdapter(expAdapter);  }

LogCat

07-02 06:24:37.317: E/AndroidRuntime(5460): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.techblogon.loginexample/com.techblogon.loginexample.ItemComments}: java.lang.NullPointerException 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.ActivityThread.access$800(ActivityThread.java:135) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.os.Handler.dispatchMessage(Handler.java:102) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.os.Looper.loop(Looper.java:136) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.ActivityThread.main(ActivityThread.java:5017) 07-02 06:24:37.317: E/AndroidRuntime(5460): at java.lang.reflect.Method.invokeNative(Native Method) 07-02 06:24:37.317: E/AndroidRuntime(5460): at java.lang.reflect.Method.invoke(Method.java:515) 07-02 06:24:37.317: E/AndroidRuntime(5460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 07-02 06:24:37.317: E/AndroidRuntime(5460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 07-02 06:24:37.317: E/AndroidRuntime(5460): at dalvik.system.NativeStart.main(Native Method) 07-02 06:24:37.317: E/AndroidRuntime(5460): Caused by: java.lang.NullPointerException 07-02 06:24:37.317: E/AndroidRuntime(5460): at com.techblogon.loginexample.ItemComments.onCreate(ItemComments.java:65) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.Activity.performCreate(Activity.java:5231) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 07-02 06:24:37.317: E/AndroidRuntime(5460): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)

Upvotes: 0

Views: 288

Answers (1)

Seth De
Seth De

Reputation: 37

After research i can't find any solutions.So i themed the activity as Dialog android:theme="@android:style/Theme.Dialog"

Upvotes: 1

Related Questions