यह लेख उन लोगों के लिए है जिनके पास ऑस्मोड्रोइड के साथ जानकारी जोड़ने में कठिनाई है और AsyncTask के साथ काम करना है, और बस उन लोगों के लिए जिन्होंने पहले ऐसा कुछ नहीं किया है। यहां मैंने लिखा कि कैसे मैंने परिवहन निगरानी सेवा में कार के बारे में डेटा प्राप्त करने के लिए एक विंडो बनाई।
लब्बोलुआब यह है कि जब आप मार्कर पर क्लिक करते हैं, तो कुछ डेटा ऑब्जेक्ट से लिया जाता है, अन्य डेटा एपीआई से लोड होता है, एप्लिकेशन डेटाबेस को लिखा जाता है, और फिर इन्फोविन्डो ऑब्जेक्ट में प्रदर्शित होता है।
हम जानकारी के विवरण के साथ एक xml फ़ाइल बनाकर शुरू करते हैं, परिवहन मानदंड के हेडर के साथ फ़ील्ड जोड़ते हैं।

MarkerInfoWindow आपको शीर्षक, विवरण, सबस्क्रिप्ट में रिकॉर्ड करने की अनुमति देता है, मैंने सभी आवश्यक रिकॉर्ड के लिए केवल डेस्क्रिप्टेन का उपयोग किया। हम बाद में हाइफ़न के साथ एक स्ट्रिंग के रूप में डेटा स्थानांतरित करेंगे।
मार्कअप निम्नानुसार है:<?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="horizontal" android:background="@drawable/balloon_overlay_white" > <ImageView android:id="@+id/bubble_image" android:layout_width="65dp" android:layout_height="65dp" android:visibility="gone" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="5dp" android:orientation="vertical" > <TextView android:id="@+id/bubble_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:maxEms="17" android:layout_gravity="left" android:layout_weight="1" android:text="Title" android:textSize="18dp" android:textIsSelectable="false" /> <Button android:id="@+id/bubble_moreinfo" android:background="@drawable/btn_moreinfo" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_weight="0" /> <TextView android:id="@+id/bubble_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="14dp" android:maxEms="17" android:text="Description" android:layout_toRightOf="@+id/model" android:layout_below="@+id/bubble_title" android:lineSpacingExtra="3dp" android:layout_marginLeft="3dp" /> <TextView android:id="@+id/model" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff6c6c6c" android:textSize="14dp" android:maxEms="17" android:text="@string/model" android:layout_below="@+id/bubble_title" android:layout_alignRight="@+id/organization" /> <TextView android:id="@+id/group" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff6c6c6c" android:textSize="14dp" android:maxEms="17" android:text="@string/group" android:layout_below="@+id/model" android:layout_alignRight="@+id/organization" /> <TextView android:id="@+id/organization" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff6c6c6c" android:textSize="14dp" android:maxEms="17" android:text="@string/organization" android:layout_below="@+id/group" /> <TextView android:id="@+id/speed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff6c6c6c" android:textSize="14dp" android:maxEms="17" android:text="@string/speed" android:layout_below="@+id/organization" android:layout_alignRight="@+id/organization" /> <TextView android:id="@+id/update" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff6c6c6c" android:textSize="14dp" android:maxEms="17" android:text="@string/update" android:layout_below="@+id/speed" android:layout_alignRight="@+id/organization" /> <TextView android:id="@+id/bubble_subdescription" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="10dp" android:maxEms="17" android:text="Address" android:layout_below="@+id/update" /> </RelativeLayout> </LinearLayout>
अगला, आवश्यक डेटा प्रदर्शित करने के लिए, हम अपना CarInfoWindow क्लास लिखते हैं: public class CarInfoWindow extends MarkerInfoWindow { Car mCar; Marker mMarker; CarInfoTask carInfoTask; Boolean stopped = false; Drawable icon; String active; public CarInfoWindow(int layoutResId, MapView mapView) { super(layoutResId, mapView); }
अब, एक मार्कर बनाते समय, यह केवल वांछित विंडो को मार्कर से बांधने के लिए रहता है
marker.setInfoWindow(infoWindow);
जोड़तोड़ के परिणामस्वरूप हमें कुछ मिलता है:

PS इस तथ्य के बावजूद कि मार्कर ट्रक का आइकन है, और विवरण में यह अल्फा रोमियो है, सब कुछ सही ढंग से काम करता है।