Search This Blog

Showing posts with label Examples. Show all posts
Showing posts with label Examples. Show all posts

Tuesday, November 7, 2017

Android Working with WebView - Building a App Browser

Android’s Web View permits you to integrate a webpage as an area of the app. Web View comes with all the options that of a desktop browser like managing history, cookies, HTML 5 support and heap a lot of. victimization web view you'll be able to build very cool apps like group action HTML 5 games within the app.


In this article we tend to  planning to learn the essential usage of Web View ranging from displaying a netpage to putting together an easy in-app browser that has some web site and search web address.

1:Create a android project in MainActivity.xml put below code for web browser design

main_activity.xml :

 <?xml version="1.0" encoding="utf-8"?>  
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
 xmlns:app="http://schemas.android.com/apk/res-auto"  
 xmlns:tools="http://schemas.android.com/tools"  
 android:layout_width="match_parent"  
 android:layout_height="match_parent"  
 android:padding="10dp"  
 tools:context="com.example.aaru.mybrowser.MainActivity"> 
 <EditText  
 android:id="@+id/editSearch"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentLeft="true"
 android:layout_alignParentStart="true"
 android:layout_alignParentTop="true"
 android:ems="10"
 android:hint="https://www.google.com"
 android:inputType="none" />
 <Button  
 android:id="@+id/buttonSearch"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentEnd="true"
 android:layout_alignParentRight="true"
 android:backgroundTint="@color/colorAccent"
 android:layout_alignParentTop="true"
 android:layout_toRightOf="@+id/editSearch"
 android:text="Search" />
 <Button  
 android:id="@+id/buttonGoogle"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:backgroundTint="#f75252"
 android:layout_marginTop="96dp"
 android:text="Google"
 android:layout_below="@+id/buttonSearch"
 android:layout_alignParentLeft="true"
 android:layout_alignParentStart="true"
 android:layout_alignParentRight="true"
 android:layout_alignParentEnd="true" /> 
 <Button  
 android:id="@+id/buttonFacebook"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_marginTop="58dp"
 android:text="Facebook"
 android:layout_below="@+id/buttonGoogle"
 android:layout_alignParentLeft="true"
 android:layout_alignParentStart="true"
 android:backgroundTint="#45c2c9"
 android:layout_alignParentRight="true"
 android:layout_alignParentEnd="true" /> 
 <Button  
 android:id="@+id/buttonGmail"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentEnd="true"
 android:layout_alignParentLeft="true"
 android:layout_alignParentRight="true"
 android:backgroundTint="#b34fda"
 android:layout_alignParentStart="true"
 android:layout_below="@+id/buttonFacebook"
 android:layout_marginTop="60dp"
 android:text="Gmail" /> 
 </RelativeLayout>  

Main Activity.java : In this class implantation the web browser design


 package com.example.aaru.mybrowser;
 import android.content.Intent;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;
 import android.widget.EditText;
 public class MainActivity extends AppCompatActivity implements View.OnClickListener 
{ 
 Button buttonSearch,buttonGoogle,buttonFacebook,buttonGmail;  
   EditText editSearch; 
 @Override  
protected void onCreate(Bundle savedInstanceState) { 
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main); 
 editSearch=(EditText)findViewById(R.id.editSearch);
 buttonSearch= (Button) findViewById(R.id.buttonSearch);
 buttonGoogle= (Button) findViewById(R.id.buttonGoogle); 
 buttonFacebook= (Button) findViewById(R.id.buttonFacebook); 
 buttonGmail= (Button) findViewById(R.id.buttonGmail);  
     //all id get
 buttonSearch.setOnClickListener(this); 
 buttonGoogle.setOnClickListener(this); 
 buttonFacebook.setOnClickListener(this); 
 buttonGmail.setOnClickListener(this); 
 }  
   @Override
 public void onClick(View v) {
 Intent i=new Intent(MainActivity.this,WebViewActivity.class);
 if (v.equals(buttonSearch)){
 String url=editSearch.getText().toString();
 i.putExtra("k1",url);  
       startActivity(i); 
 }else if (v.equals(buttonGoogle))
{ 
 i.putExtra("k1","https://google.co.in"); 
 startActivity(i); 
 }else if (v.equals(buttonFacebook)){ 
 i.putExtra("k1","https://facebook.com"); 
 startActivity(i); 
 }else if (v.equals(buttonGmail)){
 i.putExtra("k1","https://mail.google.com"); 
 startActivity(i); 
 }  
   }  
 }  




2.Create empty activity name is webview activity put below code in web_view_activity.xml and WebViewActivity.java


web_view_activity.xml :



 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
 xmlns:app="http://schemas.android.com/apk/res-auto"  
 xmlns:tools="http://schemas.android.com/tools"  
 android:layout_width="match_parent"  
 android:layout_height="match_parent"  
 android:orientation="vertical"  
 tools:context="com.example.aaru.mybrowser.WebViewActivity">  
 <WebView  
 android:layout_width="match_parent"  
 android:layout_height="match_parent"  
 android:id="@+id/webView"  
 ></WebView>  
 </LinearLayout>  

WebViewActivity.java :


 package com.example.aaru.mybrowser;  
 import android.support.v7.app.AppCompatActivity;  
 import android.os.Bundle;  
 import android.webkit.WebView;  
 import android.webkit.WebViewClient;  
 import android.widget.Toast;  
 public class WebViewActivity extends AppCompatActivity {  
   WebView webView;  
   @Override 
 protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_web_view);  
     webView=(WebView)findViewById(R.id.webView);  
     String url=getIntent().getStringExtra("k1");  
     if (url.contains("https://")){  
       webView.loadUrl(url);  
       webView.setWebViewClient(new WebViewClient());  
       webView.getSettings().setJavaScriptEnabled(true);  
       //let's run it  
       //Give a Internet Permission in manifests file  
     }else {  
       Toast.makeText(this, "Something Went wrong", Toast.LENGTH_SHORT).show();  
     }  
   }  
 }  









>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Enjoy Coding<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Custom ViewPager with Image using PageAdapter.

Screen slides are transitions between one entire screen to another and are common with UIs like setup wizards or slideshows. This lesson shows you how to do screen slides with a  View Pager provided by the support library. View Pages can animate screen slides automatically. 

This example show how to implement View Pager with custom Pager Adapter. 


Steps:1 Below is my MainActivity name is MyViewPager.class





my_pageviwer.xml : Add android.support.v4.view.ViewPager  widgets in your 
                                          MainActivity.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:app="http://schemas.android.com/apk/res-auto"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:id="@+id/linearlayout"  
   tools:context="com.example.aaru.costomizegride.MyViewPager"  
 >  
   <android.support.v4.view.ViewPager  
     android:layout_width="match_parent"  
     android:layout_height="match_parent"  
     android:id="@+id/viewPager"  
     ></android.support.v4.view.ViewPager>  
 </LinearLayout>  

MyViewPager.class: get View Pager ID add some dummy text in arraylist.

 package com.example.aaru.costomizegride;  
 import android.support.v4.view.ViewPager;  
 import android.support.v7.app.AppCompatActivity;  
 import android.os.Bundle;  
 import java.lang.reflect.Array;  
 import java.util.ArrayList;  
 public class MyViewPager extends AppCompatActivity {  
 ArrayList<String>alName=new ArrayList<String>();  
 @Override protected void onCreate(Bundle savedInstanceState) {  
 super.onCreate(savedInstanceState);  
 setContentView(R.layout.activity_my_view_pager);  
 ViewPager viewPager= (ViewPager) findViewById(R.id.viewPager);  
 for (int i=0;i<8;i++){  
 alName.add("Name "+(i+1));  
 }  
 CustomviewPager customviewPager=new CustomviewPager(alName,MyViewPager.this);  
 viewPager.setAdapter(customviewPager);  
 }  
 }  


pagerraw.xml  : Create xml layout i have create pagerraw.xml and add imageview and text.


 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:orientation="vertical"  
   >  
   <ImageView  
     android:layout_width="match_parent"  
     android:layout_height="400dp"  
     android:id="@+id/imageView"  
     android:src="@drawable/sample_0"  
     />  
   <TextView  
     android:id="@+id/textView"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:text="Puppy"  
     android:layout_gravity="center"  
     android:textSize="20dp"    />  
 </LinearLayout>  






CustomviewPager .class: Create a Java class name is customadapter and extend with  pager adapter. 


 package com.example.aaru.costomizegride;  
 import android.content.Context;  
 import android.support.v4.view.PagerAdapter;  
 import android.support.v4.view.ViewPager;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.LinearLayout;  
 import android.widget.TextView;  
 import java.util.ArrayList;  
 /** * Created by Aaru on 9/28/2017. */  
 public class CustomviewPager extends PagerAdapter {  
   ArrayList<String> alName=new ArrayList<String>();  
   Context context;  
   LayoutInflater layoutInflater;  
   public CustomviewPager(ArrayList<String> alName, Context context){  
     this.alName=alName;  
     this.context=context;  
      layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
   }  
   @Override  public int getCount() {  
     return alName.size();  
   }  
   @Override  public boolean isViewFromObject(View view, Object object) {  
     return view==((LinearLayout)object);  
   }  
   @Override  public void destroyItem(ViewGroup container, int position, Object object) {  
     container.removeView((LinearLayout)object);  
   }  
   @Override  public Object instantiateItem(ViewGroup container, int position) {  
     View view =layoutInflater.inflate(R.layout.pagerraw,container,false);  
     TextView textView=(TextView)view.findViewById(R.id.textView);  
     textView.setText(alName.get(position));  
     ((ViewPager)container).addView(view);  
     return view;  
   }  
 }  








>>>>>>>>>>>>>>>>>>.Enjoy Coding<<<<<<<<<<<<<<<<<<<

Monday, November 6, 2017

Custom Gride View with image,text using BaseAdapter.

In this tutorial we are create custom gride view.gride view same as custom listview.
first create project than create java class and xml layout.code show bewlo



-add GridView widgets in activity_main.xml

activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:app="http://schemas.android.com/apk/res-auto"   
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:padding="10dp"  
   tools:context="com.example.aaru.costomizegride.MainActivity"  
 >  
  <GridView   android:id="@+id/gridView"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    android:numColumns="3"  
    android:gravity="center"   />  
 </RelativeLayout>  


-get id and put some dummy images in drawble folder and in array.

MainActivity.class

 package com.example.aaru.costomizegride;  
 import android.support.v7.app.AppCompatActivity;  
 import android.os.Bundle;  
 import android.view.View;  
 import android.widget.AdapterView;  
 import android.widget.GridView;  
 import android.widget.Toast;  
 import java.util.ArrayList;  
 public class MainActivity extends AppCompatActivity {  
   GridView gridView;  
   ArrayList<String>alName=new ArrayList<>();  
   ArrayList<Integer>alImage=new ArrayList<>();  
   @Override  protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
     gridView= (GridView) findViewById(R.id.gridView);  
     for (int i=0;i<24;i++){  
       alName.add("Name "+(i+1));  
     }  
     alImage.add(R.drawable.sample_0);  
     alImage.add(R.drawable.sample_1);  
     alImage.add(R.drawable.sample_2);  
     alImage.add(R.drawable.sample_3);  
     alImage.add(R.drawable.sample_4);  
     alImage.add(R.drawable.sample_5);  
     alImage.add(R.drawable.sample_6);  
     alImage.add(R.drawable.sample_7);  
     alImage.add(R.drawable.sample_0);  
     alImage.add(R.drawable.sample_1);  
     alImage.add(R.drawable.sample_2);  
     alImage.add(R.drawable.sample_3);  
     alImage.add(R.drawable.sample_4);  
     alImage.add(R.drawable.sample_5);  
     alImage.add(R.drawable.sample_6);  
     alImage.add(R.drawable.sample_7);  
     alImage.add(R.drawable.sample_0);  
     alImage.add(R.drawable.sample_1);  
     alImage.add(R.drawable.sample_2);  
     alImage.add(R.drawable.sample_3);  
     alImage.add(R.drawable.sample_4);  
     alImage.add(R.drawable.sample_5);  
     alImage.add(R.drawable.sample_6);  
     alImage.add(R.drawable.sample_7);  
     CustomAdapter customAdapter=new CustomAdapter(alName,alImage,MainActivity.this);  
     gridView.setAdapter(customAdapter);  
     gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       @Override      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {  
         Toast.makeText(MainActivity.this, alName.get(position), Toast.LENGTH_SHORT).show();  
       }  
     });  
   }  
 }  


-create xml layout and put below code.

raw.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="wrap_content"  
   android:layout_height="wrap_content"  
   android:orientation="vertical"  
   >  
   <ImageView  
     android:layout_width="90dp"  
     android:layout_height="90dp"  
     android:id="@+id/imageView"  
     android:src="@mipmap/ic_launcher"  
     />  
   <TextView   
     android:id="@+id/textName"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_alignEnd="@+id/imageView"  
     android:layout_alignRight="@+id/imageView"  
     android:layout_below="@+id/imageView"  
     android:layout_marginEnd="26dp"  
     android:layout_marginRight="26dp"  
     android:text="Name" />  
 </LinearLayout>  


-create a class name is customadapter inflate the raw xml .

CustomAdapter.class


  package com.example.aaru.costomizegride;  
 import android.content.Context;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.BaseAdapter;  
 import android.widget.ImageView;  
 import android.widget.TextView;  
 import android.widget.Toast;  
 import java.util.ArrayList;  
 /** * Created by Aaru on 9/28/2017. */  
 public class CustomAdapter extends BaseAdapter {  
   ArrayList<String> alName = new ArrayList<>();  
   ArrayList<Integer> alImage;  
   Context context;  
   LayoutInflater layoutInflater;  
   public CustomAdapter(ArrayList<String> alName, ArrayList<Integer> alImage, Context context) {  
     this.alName = alName;  
     this.alImage=alImage;  
     this.context = context;  
     layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
   }  
   @Override  public int getCount() {  
     return alName.size();  
   }  
   @Override  public Object getItem(int position) {  
     return null;  
   }  
   @Override  public long getItemId(int position) {  
     return 0;  
   }  
   @Override  public View getView(final int position, View convertView, ViewGroup parent) {  
     final View view=layoutInflater.inflate(R.layout.raw,null);  
     TextView textName=(TextView)view.findViewById(R.id.textName);  
     ImageView imageView =(ImageView) view.findViewById(R.id.imageView);  
     imageView.setImageResource(alImage.get(position));  
     textName.setText(alName.get(position));  
     textName.setOnClickListener(new View.OnClickListener() {  
       @Override      public void onClick(View v) {  
         Toast.makeText(context, alName.get(position), Toast.LENGTH_SHORT).show();  
       }  
     });  
     return view;  
   }  
 }  

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Enjoy Coding>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Custom List View with Images and text using BaseAdapter.


In this tutorial we are create custom list view..so let's start first we create MainActivity than we create one class name is CustomAdapter and create on XML file name is raw and inflate the raw.xml file in CustomAdapter and Create the CustomAdapter Object in MainActivity than we pass the object in list view and we also do Item click on image view and image was show in another activity .following below steps:


-in main_activity.xml add List View widgets main_activity.xml


 <?xml version="1.0" encoding="utf-8"?><  
 LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:app="http://schemas.android.com/apk/res-auto"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:orientation="vertical"  
   android:padding="10dp"  
   tools:context="com.example.aaru.customizelistview.MainActivity">  

   <ListView  android:layout_width="match_parent"   
   android:layout_height="match_parent"  
   android:id="@+id/listView"  >  
   </ListView>   

  </LinearLayout>  



-In this Part get List View id in MainActivity.java  and put dummy images in drawble folder. 
MainActivity.java


 package com.example.aaru.customizelistview;  
 import android.support.v7.app.AppCompatActivity;  
 import android.os.Bundle;  
 import android.view.View;  
 import android.widget.AdapterView;  
 import android.widget.ListView;  
 import android.widget.Toast;  
 import java.util.ArrayList;  
 public class MainActivity extends AppCompatActivity {  
 ListView listView;  
   ArrayList<String> alName=new ArrayList<>();    
  ArrayList<Integer> alImage=new ArrayList<>();  
   @Override  protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);     
     setContentView(R.layout.activity_main);  
     listView= (ListView) findViewById(R.id.listView);  
     for(int i=0;i<8;i++)  
     {  
       alName.add("Name "+(i+1));  
     }  
     alImage.add(R.drawable.sample_0);      
     alImage.add(R.drawable.sample_1);     
     alImage.add(R.drawable.sample_2);   
     alImage.add(R.drawable.sample_3);  
     alImage.add(R.drawable.sample_4);  
     alImage.add(R.drawable.sample_5);  
     alImage.add(R.drawable.sample_6);  
     alImage.add(R.drawable.sample_7);  
     CustomAdapter adapter=new CustomAdapter(alName,alImage,MainActivity.this);   
      listView.setAdapter(adapter);  
    //below is row item click not a item click lisner  
     listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       @Override   
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) {  
     Toast.makeText(MainActivity.this, alName.get(position), Toast.LENGTH_SHORT).show();  
       }  
     });  
   }  
 }  


-Create Extra layout file name is raw right click on project package >new>xml>layoout

raw.xml



 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:app="http://schemas.android.com/apk/res-auto"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="wrap_content"  
   android:orientation="horizontal"  
   android:padding="10dp"  
   tools:context="com.example.aaru.customizelistview.MainActivity">  
   <ImageView   
     android:id="@+id/imageView"  
     android:layout_width="100dp"  
     android:layout_height="100dp"  
     app:srcCompat="@mipmap/ic_launcher" />  
   <LinearLayout  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:orientation="vertical">  
     <TextView  
       android:id="@+id/txtName"  
       android:layout_width="wrap_content"  
       android:layout_height="wrap_content"  
       android:layout_weight="1"  
       android:text="TextView"  
       android:layout_gravity="center"  
       android:textSize="25sp" />  
   </LinearLayout></LinearLayout>  

-Create extra class  name is Custom adapter extend with base adapter . CustomAdapter.java

 package com.example.aaru.customizelistview;  
 import android.content.Context;  
 import android.content.Intent;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.BaseAdapter;  
 import android.widget.ImageView;  
 import android.widget.TextView;  
 import android.widget.Toast;  
 import java.util.ArrayList;  
 /** * Created by Aaru on 9/27/2017. */  
 public class CustomAdapter extends BaseAdapter{  
   ArrayList<String> alName=new ArrayList<>();  
   ArrayList<Integer> alImage=new ArrayList<>();  
   Context cotext;  LayoutInflater inflator;  
  public CustomAdapter(ArrayList<String> alName, ArrayList<Integer> alImage, Context cotext)  
   {  
     this.alImage=alImage;  
     this.alName=alName;  
     this.cotext=cotext;  
     inflator=(LayoutInflater)cotext.getSystemService(cotext.LAYOUT_INFLATER_SERVICE);  
   }  
   @Override  
   public int getCount() {  
    //alNam.size() is print raw equal to alName Size.  
     return alName.size();  
   }  
   @Override  
   public Object getItem(int position) {  
     return null;  
   }  
   @Override  
   public long getItemId(int position) {  
     return 0;  
   }  
   @Override  
   public View getView(final int position, final View convertView, final ViewGroup parent)  
   {  
     final View view=inflator.inflate(R.layout.raw,null);  
     TextView txtName=(TextView)view.findViewById(R.id.txtName);  
     ImageView image=(ImageView)view.findViewById(R.id.imageView);  
     image.setImageResource(alImage.get(position));  
     txtName.setText(alName.get(position));  
     image.setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View v) {  
     //this is onItem Click Lisner when user is click on  
     // Image we post the the data to another activity  
         Intent i=new Intent(cotext,Main2Activity.class);  
         i.putExtra("image",alImage.get(position));  
         cotext.startActivity(i);  
       }  
     });  
     return view;  
   }  
 }  
>>>>>>>>>>>>>>>CustomListview is done>>>>>>>>>>>>>>

Important Part !!

listview setup is complete than setup the on item click and raw click .

rawclick is already done is MainActivity.class.

so we going to itemclick let's do it

>>You show item click listener in CustomAdpater.class 
>>we put item click listener in image and get the image position when user is click on    image    and pass  the    Image Data another activity using Intent. lets create a one Extra activity name is  Main2Activity   for getting image.



activity_main2.xml




 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:app="http://schemas.android.com/apk/res-auto"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:orientation="vertical"  
   tools:context="com.example.aaru.customizelistview.Main2Activity">  
   <ImageView  
     android:layout_width="match_parent"  
     android:layout_height="match_parent"  
     android:id="@+id/imageView"   
     />  
 </LinearLayout>  





Main2Activity.class




 package com.example.aaru.customizelistview;  
 import android.support.v7.app.AppCompatActivity;  
 import android.os.Bundle;  
 import android.widget.ImageView;  
 public class Main2Activity extends AppCompatActivity {  
   ImageView imageView;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main2);  
     imageView=(ImageView)findViewById(R.id.imageView);  
     int i=getIntent().getIntExtra("image",0);  
     imageView.setImageResource(i);  
   }  
 }  








>>>>>>>>>>>>.Enjoy Coding>>>>>>>>>>>>>>>>