2011-01-26 18 views
6

मेरे पास ListActivity है जो आइटमों की सूची दिखाता है। मैंने विस्तृत दृश्य के लिए एक और layout तैयार किया जिसमें आइटम का नाम, पता, फोन नंबर और छवि शामिल है। यदि मैं अपने ListActivity को बंद किए बिना क्लिक किया गया है, तो मैं इन आइटम्स को पॉपअप विंडो में विस्तृत दिखाना चाहता हूं।पॉपअप विंडो में कोई गतिविधि कैसे खोलें?

मैं यह कैसे कर सकता हूं?

उत्तर

5

ऐसा करने के लिए AlertDialog उपयोग कर सकते हैं। यहां देखें http://developer.android.com/guide/topics/ui/dialogs.html। और एक कस्टम संवाद बनाने के लिए स्क्रॉल करें। उदाहरण है:

AlertDialog.Builder builder; 
AlertDialog alertDialog; 

Context mContext = getApplicationContext(); 
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); 
View layout = inflater.inflate(R.layout.custom_dialog, 
           (ViewGroup) findViewById(R.id.layout_root)); 

TextView text = (TextView) layout.findViewById(R.id.text); 
text.setText("Hello, this is a custom dialog!"); 
ImageView image = (ImageView) layout.findViewById(R.id.image); 
image.setImageResource(R.drawable.android); 

builder = new AlertDialog.Builder(mContext); 
builder.setView(layout); 
alertDialog = builder.create(); 
+0

'mContext = getAplicationContext(); 'अपवाद का कारण बनता है। इसके बजाय 'YourActivity.this' का उपयोग करें क्योंकि मुझे लगता है कि यह एक बग है – Onimusha

4

आप quickAction like the Twitter app का उपयोग कर सकते हैं या Activity पर अपने मेनिफेस्ट में निर्दिष्ट android:theme="@android:style/Theme.Dialog" के साथ एक नया Activity शुरू कर सकते हैं।

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