2012-07-19 9 views
12

मेरे पास छवि ग्रिडव्यू है और मैं छवियों एक को से गैलरी या कैमरे से प्राप्त छवि से ग्रिडव्यू में जोड़ने के लिए जोड़ना चाहता हूं।छवि के साथ ग्रिडव्यू को सिर्फ गैलरी से चुना गया है या कैमरे से कैप्चर किया गया है

+0

हे मैं एक प्रश्न मुझे कुछ जानकारी प्रदान करें है .... यू ग्रिड दृश्य या सभी छवि पर गैलरी से चयनित छवि को जोड़ने के लिए ग्रिड दृश्य जो गैलरी में मौजूद हैं पर दिखाया जा करना चाहते हैं .. .. –

उत्तर

4

आप अपने मामले में क्या कर सकते हैं हमेशा आपके ग्रिड व्यू के अंतिम आइटम को सौंपा गया एक चित्र होता है। उस अंतिम आइटम पर क्लिक करके आप एक पॉपअप बना सकते हैं जो आपको गैलरी या कैमरे के लिए ले जा रहा है। अब यदि उपयोगकर्ता बैक बटन पर क्लिक करता है या रद्द करने का निर्णय करता है तो अपने ग्रिड व्यू में आखिरी आबादी वाली '+' साइन छवि को दिखाते रहें, अन्यथा यदि कोई अन्य विकल्प चुना गया है तो आप onActivityResult(). में परिणाम प्राप्त करके वांछित कार्रवाई पर नेविगेट कर सकते हैं कोड सकारात्मक है और आप के साथ जारी रख सकते हैं:

1) Delete the last item from grid view i.e, the '+' sign image 
2) Appending the image either taken from camera or gallery 
3) Appending the image having '+' sign itself 

और हमेशा गैलरी के लिए नेविगेट करने के लिए संवाद करने के लिए यह बात या कैमरे से क्लिक करने के लिए अपने ग्रिड दृश्य के अंतिम आइटम के लिए एक शर्त डाल दिया। अन्य वस्तुओं के लिए आप अपनी वांछित आवश्यकताओं के साथ जारी रख सकते हैं।

अगर यह मदद करता है तो मुझे बताएं।

धन्यवाद

2

मैं एसडी कार्ड में लगता है कि नीचे दिए गए लिंक आपको लगता है कि बनाने के लिए मदद मिलेगी .. फ़ोल्डर में

+0

वास्तव में मैं देख रहा हूं और यूआई को रद्द कर रहा हूं - ग्रिडव्यू http://stackoverflow.com/q/14591132/1012284 पर गतिशील रूप से बटन जोड़ें –

1

रखें छवियों [छवियाँ]

public class ChannelImageAdapter extends BaseAdapter { 

int mGalleryItemBackground; 
private Context mContext; 
File[] images; 
File[] files; 
public ChannelImageAdapter(Context c, int folderID) { 
    mContext = c; 

    File dir = new File(Environment.getExternalStorageDirectory() + "/images"); 
    files = dir.listFiles(); 
    images = files[folderID].listFiles(); 

} 
public int getCount() { 
    return images.length; 
} 
public Object getItem(int position) { 
    return images[position].getAbsolutePath(); 
} 
public long getItemId(int position) { 
    return position; 
} 
public String getAlbumName(int folderID) { 
    return files[folderID].getName(); 
} 
public View getView(int position, View convertView, ViewGroup parent) { 

    ImageView imageView; 
    //Bitmap bm = BitmapFactory 
    //  .decodeFile(images[position].getAbsolutePath()); 
    if (convertView == null) { 
     imageView = new ImageView(mContext); 
     imageView.setLayoutParams(new GridView.LayoutParams(100, 100)); 
     imageView.setScaleType(ImageView.ScaleType.FIT_XY); 
     imageView.setPadding(5, 10, 5, 10); 
    } else { 
     imageView = (ImageView) convertView; 
    } 
    imageView.setImageBitmap(Bitmap.decode(images[position].getAbsoluteFile())); 
    return imageView; 

} 

}

संबंधित मुद्दे