Skip to content Skip to sidebar Skip to footer

Tab Application Crash During Runtime

I am new to android development and I've been creating an application containing two tabs . in one tab a Grid containing images will be displayed and on the other another page will

Solution 1:

Your problem is that ImageAdapter is not an Activity and therefore Android has no idea how to instantiate it as though it were one.

You'll need to create an Activity which holds your ImageAdapter and within that Activity set the adapter on its GridView.

First, change img_layout.xml to this:

<?xml version="1.0" encoding="utf-8"?><GridViewxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/img_grid"android:layout_width="match_parent"android:layout_height="match_parent" >

Let's call your new Activity ImageGridActivity. Within your ImageGridActivity.onCreate() you'll do:

setContentView(R.id.img_layout);
GridViewgrid= (GridView)findViewById(R.id.img_grid);
grid.setAdapter(newImageAdapter(this));

Solution 2:

You are trying to set one of the tabs with ImageAdapter, but ImageAdapter is not an Activity. You can only set Activity classes as a tab. So Remove the below code

Intent imgIntent = newIntent(this,ImageAdapter.class);
imgspec.setContent(imgIntent);

Post a Comment for "Tab Application Crash During Runtime"