I'm a new programmer and new in Android. I'm using this example http://www.androidhive.info/2012/09/android-adding-search-functionality-to-listview/ and it works great.
Now I want to make the items (Dell, Samsung Galaxy S3, etc) to call a function to open a new activity with different information each.
For example:
If I touch Dell, a new Activity has to show up showing me information about Dell. If I touch Samsung, the same thing.
I Googled but couldn't find anything helpfull, any hint? I think this is basic, but I'm new so I don't really know where to start
You start new activities with intents. One method to send data to an intent is to pass a class that implements parcelable in the intent. Take note you are passing a copy of the class.
http://developer.android.com/reference/android/os/Parcelable.html
Here I have an onItemClick. I create intent and putExtra an entire class into the intent. The class I'm sending has implemented parcelable. Tip: You only need implement the parseable over what is minimally needed to re-create the class. Ie maybe a filename or something simple like a string something that a constructor can use to create the class. The new activity can later getExtras and it is essentially creating a copy of the class with its constructor method.
Here I launch the kmlreader class of my app when I recieve an onclick in the listview.
Note: below summary is a list of the class that I am passing so get(position) returns the class infact it is the same list that populates the listview
later in the new activity I pull out the parseable class with
Good Luck Danny117
You should definitely extend you
ArrayListAdapter
and implement this in yourgetView()
method. The second parameter (aView
) should be inflated if it's value isnull
, take advantage of it and set it anonClickListener()
just after inflating.Suposing it's called your second
getView()
's parameter is calledconvertView
:If you want some info on how to extend
ArrayListAdapter
, I recommend this link.I was able to go around the whole thing by replacing the context reference from
this
orContext.this
togetapplicationcontext
.well in your
onitemClick
you will send the selected value likedeal
, and send it in your intent when opening new activity and in your new activity get the sent data and related to selected item will display your datato get the name from the
list
to set data in intent
to get the data in second activity