[Android Q&A, Help & Troubleshooting] Kishore_B:
Hi,

i have a Listview...click on Listitem open image and text after open full image...pls help full code..

i have a error message :Activity Not Found Exception...Pls sharing the code This i s i wright code... MainActivity.java

package com.example.prj_10;

import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends Activity { ListView list; String[] kkTitles; String[] kkDescriptions; int[] images={R.drawable.anamrama1,R.drawable.aruna2,R.drawable.mukesh3,R.drawable.nagendra4,R.drawable.balaraju5};

[MENTION=439709]override[/MENTION]

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Resources res=getResources();

kkTitles=res.getStringArray(R.array.titles);

kkDescriptions=res.getStringArray(R.array.descriptions);

list=(ListView) findViewById(R.id.listView1);

MainAdapter adapter=new MainAdapter(this,kkTitles,images,kkDescriptions);

list.setAdapter(adapter);

GridView gridView = (GridView) findViewById(R.id.grid_view);

// Instance of ImageAdapter Class

gridView.setAdapter(new ImageAdapter(this));

/**

* On Click event for Single Gridview Item

* */

gridView.setOnItemClickListener(new OnItemClickListener() {

[MENTION=439709]override[/MENTION]

public void onItemClick(AdapterView<?> parent, View v,

int position, long id) {

// Sending image id to FullScreenActivity

Intent i = new Intent(getApplicationContext(), FullImage.class);

// passing array index

i.putExtra("id", position);

startActivity(i);

}

});

}

class MainAdapter extends ArrayAdapter<String>

{

Context context;

int[] images;

String[] titleArray;

String[] descriptionArray;

private ImageView myImage1;

MainAdapter(Context c,String[] titles,int imgs[],String[] desc)

{

super(c,R.layout.activity_main,R.id.textView1,titles);

this.context=c;

this.images=imgs;

this.titleArray=titles;

this.descriptionArray=desc;

}

[MENTION=439709]override[/MENTION]

public View getView(int position,View convertView,ViewGroup parent){

LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View row=inflater.inflate(R.layout.activity_main,parent,false);

ImageView myImage1=(ImageView) row.findViewById(R.id.imageView1);

TextView myTitle=(TextView) row.findViewById(R.id.textView1);

TextView myDescription=(TextView) row.findViewById(R.id.textView2);

myImage1.setImageResource(images[position]);

myTitle.setText(titleArray[position]);

myDescription.setText(descriptionArray[position]);

return row;

}

} }

ImageAdapter.java

package com.example.prj_10;

import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter { private Context mContext;

// Keep all Images in array

public Integer[] mThumbIds = {

R.drawable.anamrama1,

};

// Constructor

public ImageAdapter(Context c){

mContext = c;

}

[MENTION=439709]override[/MENTION]

public int getCount() {

return mThumbIds.length;

}

[MENTION=439709]override[/MENTION]

public Object getItem(int position) {

return mThumbIds[position];

}

[MENTION=439709]override[/MENTION]

public long getItemId(int position) {

return 0;

}

[MENTION=439709]override[/MENTION]

public View getView(int position, View convertView, ViewGroup parent) {

ImageView imageView = new ImageView(mContext);

imageView.setImageResource(mThumbIds[position]);

imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

imageView.setLayoutParams(new GridView.LayoutParams(70, 70));

return imageView;

}

}

FullImage.java

package com.example.prj_10;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.ImageView;

public class FullImage extends Activity {

[MENTION=439709]override[/MENTION]

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// get intent data

Intent i = getIntent();

// Selected image id

int position = i.getExtras().getInt("id");

ImageAdapter imageAdapter = new ImageAdapter(this);

ImageView imageView = (ImageView) findViewById(R.id.full_image_view1);

imageView.setImageResource(imageAdapter.mThumbIds[position]);

}

}

activity_main.xml

<ListView

android1:id="@+id/listView1"

android1:layout_width="wrap_content"

android1:layout_height="wrap_content"

android1:layout_alignParentLeft="true"

android1:layout_alignParentTop="true" >

</ListView>

<GridView

android:id="@+id/grid_view"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:columnWidth="150dp"

android:horizontalSpacing="10dp"

android:verticalSpacing="40dp"

android:numColumns="3"

android:gravity="center"

android:stretchMode="columnWidth" >

<TextView

android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/textView1"

android:layout_alignParentRight="true"

android:layout_below="@+id/textView1"

android:layout_marginTop="22dp"

android:text="Small Text"

android:textAppearance="?android:attr/textAppearanceSmall"

android:textStyle="bold" />