I'm a little poor in Java or better to say that OOP has a strange problem, I wonder if this is possible is. I have a class
Private Arrestist I used later
see public getView (int position, seeviewview, ViewGroup parent) {see vi = convertView; See holder holder; If (convertView == faucet) {vi = inflater.inflate (R.layout.custom_gallery, null); Holder = new viewholder (); Holder.txt = (TextView) vi.findViewById (R.id.text); Holder = .image = (ImageView) vi.findViewById (R.id.image); Holder.road = (linear layout) vi.findViewById (R. Id.Rot); Vi.setTag (holder); } And holder = (seeholder) vi.getTag (); // I use this which solves my problem if (Data: GalleryTystemper Example) example {GalleryTestParser mParser = (GalleryTestParser) data.get (status); Holder.text.setText (mParser.Name); Holder.image.setTag (mParser.galleryThumbiPad); Holder.root.setTag (mParser); ImageLoader.DisplayImage (mParser.galleryThumbiPad, Activity, Holder Image); } Return vi; } Edit: If I want the data gallery to be of toppers or something other than doing something else. Earlier I was trying to ArrayList & LT; GalleryTestParser & gt; MStatus is in the manufacturer but this class is specific what I want, that I should know somehow from the object of the array, what kind of type is that I type the object with the array inserted in that type. Is this possible?
To expand on StevieB's answer (and add a turning point): You can use an interface with a solid key, to identify which concrete square you can use Working:
Public Abstract Interface GenericParser {public string getType (); } Public Category Gallery applies to theTestpressor GenericParser {public string getType () {return "gallery"; }} Public A (Activity A, list & lt ;? genericpers & gt; mStatus provides) {GenericParser items = mStatus.get (0); If (item.getType (.) Equals ("Gallery")) {item = (GalleryTestParser) item; // What items with the item}} This avoids "example", which gives you more control over handling For example, GetType () may return something like a list of more complex, capabilities in the future
Ideally, however, you will be able to transfer execution in GalleryTestParser, which will make code cleaner May want to.
Public abstract interface GenericParser {Public executed null (); } Public class GalleryTestParser GenericParser {Public execution of Zero ()} {// stuff with item} applies} Public A (Activity A, mStatus extends from & gt; genericParser & gt;) {GenericParser items = mStatus.get (0); Item.execute (); }
Comments
Post a Comment