I have Listview
is that animals, showing different images of birds, reptiles. List view is working fine Now when the user clicks on any photo, he wants it to appear in ImageView
. It is below ImageView
below listview
. Therefore, when a user clicks any image in listview
, then it should appear in the Imageview
.
Apart from this there is a button. Now I want to achieve this when users choose any image and press the OK button, the peticular image should be shown on the image view of other activity. I know that I can ID sent via intent.putextra ()
do, but the problem is how to obtain the ID of a specific picture the first to
Source Code
public class MainActivity2 Extended ActionBarActivity {Personalized TypedArray ListIcons; View private horizontal list list; Private Archieist & Lt; Veterinary Items & gt; SuitItems; Private animal list adapter adapter = 1 tap; / ** [an array * / string of strings to populate the drop-down list] action = new String [] { "bookmark", "Subscribe", "Share"}; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_main_activity2); ListView = (horizontalviewview) powerviewbid (rid suits_list); Animalism = new arreelist & lt; Veterinary Items & gt; (); / ** dropdown list * / Arrayadapter & lt; String & gt; Create an array adapter to populate. Adapter = new array adapter & lt; String & gt; (GetBaseContext (), AndroidRout Outout. Simple_spir_dropdown_item, verb); / ** Enable dropdown list navigation for action bar * / getSupportActionBar () SetNavigationMode (ActionBar.NAVIGATION_MODE_LIST); GetSupportActionBar () SetDisplayShowTitleEnabled (wrong); GetSupportActionBar () setDefaultDisplayHomeAsUpEnabled (true). GetSupportActionBar () SetTitle ("+" "+" "); / ** defining navigation listener * / android.support.v7.app.ActionBar.OnNavigationListener navigationListener = new android.support.v7.app.ActionBar.OnNavigationListener () {@Override public boolean onNavigationItemSelected (integer itemPosition, long Itemid) {toast .makeText (getBaseContext), "You chose:" + Action [Item status], toast. LNNGHIHORAR) Show (); ListIcons = getResources () .obtainTypedArray (R.array.ic_launcher); // Load mouse // to strings.xml (int i = 0; i & lt; = ListIcons.length (); i ++) {AnimalsItems.add (New AnimalsListItems (ListIconskgetResourceId (I, -l) )); } Adapter1 = New suite list adapter (getApplicationContext (), suit items); Log.v (adapter1.getCount (+ + ""); ListView.setAdapter (adapter1); return false; }}; ListViewksetOnItemClickListener (new Adaptrwu. Onitemkliklist () {@Override public Aitemklik zero (Adaptrwu & lt ;? & Gt; parents, views, with the whole situation, long id) {// Status parameter, you click Status The item can get .. whatever type of type your listView is to cast it to yourItem = (object) listView.getItemAtPosition (position); // Now you can provide the image to an imageView} }); / ** Setting down the dropdown items and items to the navigation listener for the workspace * / getSupportActionBar (). SetListNavigationClallbacks (Adapters, NavigationalListers); This.overridePendingTransition (R.anim.anim_slide_in_left, R.anim.anim_slide_out_left); } < ListView
}
/ Code>, you can set a
onItemClickListener
as ListView listView1 = (ListView) findViewById (R.id.listView1); ListView1.setOnItemClickListener (new OnItemClickListener () {@Override} with an item click on ad Zero (adapter view
No comments:
Post a Comment